diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index b2684f7f3e4d0499d080dc0e4457a11a9f3ce868..2940c8dc175f1c7bb37be180cf813bb2c2e90c2b 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -21,7 +21,6 @@ group("multimedia") { "audio/audio_js_standard/AudioCapturerChangeInfo:audio_capturerchangeInfo_js_hap", "audio/audio_js_standard/AudioEventManagement:audio_eventmanagement_js_hap", "audio/audio_js_standard/AudioRendererChangeInfo:audio_rendererchangeInfo_js_hap", - "audio/audio_js_standard/AudioTonePlayer:audio_tone_player_js_hap", "audio/audio_js_standard/audioInterrupt:audio_interrupt_js_hap", "audio/audio_js_standard/audioInterruptRender:audioRenderInterrupt", "audio/audio_js_standard/audioManager:audio_manager_js_hap", @@ -59,10 +58,6 @@ group("multimedia") { "medialibrary/mediaLibrary_getThumbnail:mediaLibrary_getThumbnail_hap", "medialibrary/mediaLibrary_mediafetchoptions:mediaLibrary_mediafetchoptions_hap", "medialibrary/mediaLibrary_trash:mediaLibrary_trash_js_hap", - "userfilemgr/userfilemgr_album:userfilemgr_album_js_hap", - "userfilemgr/userfilemgr_base:userfilemgr_base_js_hap", - "userfilemgr/userfilemgr_fileAsset:userfilemgr_fileAsset_js_hap", - "userfilemgr/userfilemgr_noPermission:userfilemgr_noPermission_js_hap", ] } else { deps = [ diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/BUILD.gn b/multimedia/audio/audio_js_standard/AudioTonePlayer/BUILD.gn deleted file mode 100644 index 128bfcf9af10bd608a9420f1e709630cca51232c..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/BUILD.gn +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2022 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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("audio_tone_player_js_hap") { - hap_profile = "./src/main/config.json" - deps = [ - ":audio_tone_player_js_assets", - ":audio_tone_player_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAudioTonePlayerJsTest" - subsystem_name = "multimedia" - part_name = "multimedia_audio_framework" -} -ohos_js_assets("audio_tone_player_js_assets") { - source_dir = "./src/main/js/default" -} -ohos_resources("audio_tone_player_resources") { - sources = [ "./src/main/resources" ] - hap_profile = "./src/main/config.json" -} diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/Test.json b/multimedia/audio/audio_js_standard/AudioTonePlayer/Test.json deleted file mode 100644 index c0bb6222c6ad93319777dbc33327046c28b3b3fa..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/Test.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "description": "Configuration for audio toneplayer Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "1500000", - "package": "ohos.acts.multimedia.audio.toneplayer", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsAudioTonePlayerJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - }, - { - "type": "ShellKit", - "run-command": [ - "hilog -Q pidoff" - ] - } - ] -} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/signature/openharmony_sx.p7b b/multimedia/audio/audio_js_standard/AudioTonePlayer/signature/openharmony_sx.p7b deleted file mode 100644 index 0e9c4376f4c0ea2f256882a2170cd4e81ac135d7..0000000000000000000000000000000000000000 Binary files a/multimedia/audio/audio_js_standard/AudioTonePlayer/signature/openharmony_sx.p7b and /dev/null differ diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/config.json b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/config.json deleted file mode 100644 index 49a378fbb9154ece1ef31e2761dbe8e7cd131dae..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/config.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "app": { - "apiVersion": { - "compatible": 6, - "releaseType": "Beta1", - "target": 7 - }, - "vendor": "acts", - "bundleName": "ohos.acts.multimedia.audio.toneplayer", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": { - "default": { - "debug": true - } - }, - "module": { - "abilities": [ - { - "iconId": 16777218, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "descriptionId": 16777217, - "visible": true, - "labelId": 16777216, - "icon": "$media:icon", - "name": "ohos.acts.multimedia.audio.toneplayer.MainAbility", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "homeAbility": true, - "launchType": "standard" - } - ], - "deviceType": [ - "default", - "phone", - "tablet", - "tv", - "wearable" - ], - "mainAbility": "ohos.acts.multimedia.audio.toneplayer.MainAbility", - "distro": { - "moduleType": "entry", - "installationFree": false, - "deliveryWithInstall": true, - "moduleName": "entry" - }, - "package": "ohos.acts.multimedia.audio.toneplayer", - "name": ".MyApplication", - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MICROPHONE", - "reason": "use ohos.permission.MICROPHONE" - }, - { - "name": "ohos.permission.MANAGE_AUDIO_CONFIG", - "reason": "use ohos.permission.MANAGE_AUDIO_CONFIG" - } - ] - } - } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/app.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/app.js deleted file mode 100644 index 830070d196d86b127cea947d168bfd116f446205..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 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. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/en-US.json b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.css b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.hml b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.js deleted file mode 100644 index 67f8b8567ccc4932331b7a18a6b947340d84fb40..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2022 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 {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - this.timeout = 60000 - configService.setConfig(this) - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js deleted file mode 100644 index beadd2f1fa1daec514a3090d5b0afced3a1b8031..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js +++ /dev/null @@ -1,1312 +0,0 @@ -/* - * Copyright (C) 2022 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 audio from '@ohos.multimedia.audio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -describe('audioTonePlayer',function() { - let tonePlayerCallback = null; - let name; - let TagTone = 'AudioTonePlayerTest'; - let stringParameter = "invalid_parameter"; - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - beforeAll(function(){ - console.log('beforeAll test suit is executed'); - }) - beforeEach(function(){ - console.log('beforeEach test suit is executed'); - }) - beforeEach(function(){ - console.log('beforeEach test suit is executed'); - }) - - afterEach(function(){ - console.log('afterEach test suit is executed'); - }) - afterAll(function(){ - console.log('afterAll test suit is executed'); - }) - - async function recCallBack(info, type, name, done) { - console.info('AudioFrameworkRecLog: recCallBack : TonePlayer Function '+ JSON.stringify(name) + ', type: ' + type); - audio.createTonePlayer(info, async (err, data) => { - console.info('AudioFrameworkRecLog: TonePlayer : CREATE SUCCESS'); - if (err) { - console.error(`callback call createTonePlayer return error: ${err.message}`); - expect(true).assertFalse(); - console.info('createTonePlayer fail'); - done(); - return; - } else { - tonePlayerCallback = data; - console.error("callback call createTonePlayer return tonePlayer:" + JSON.stringify(tonePlayerCallback)); - } - tonePlayerCallback.load(type, async (err) => { - console.info('AudioFrameworkRecLog: TonePlayer : LOAD SUCCESS type: ' + type); - if (err) { - console.error(`callback call load failed error: ${err.message}`); - expect(true).assertFalse(); - console.error('callback load fail'); - done(); - return; - } else { - console.info(`callback call load success `); - } - tonePlayerCallback.start((err) => { - console.info('AudioFrameworkRecLog: TonePlayer : START SUCCESS'); - if (err) { - console.error(`callback call start failed error. ${err.message}`); - expect(true).assertFalse(); - console.error('start fail'); - done(); - return; - } else { - console.info(`callback call start success `); - } - console.error("callback stop -------------start"); - tonePlayerCallback.stop((err) => { - console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); - if (err) { - console.error(`callback call stop error. ${err.message}`); - expect(true).assertFalse(); - console.error('callback stop fail'); - done(); - return; - } else { - console.info(`callback call stop success `); - } - console.info("callback release -------------start"); - tonePlayerCallback.release((err) => { - console.info('AudioFrameworkRecLog: TonePlayer : RELEASE SUCCESS'); - if (err) { - console.error(`callback call release failed error. ${err.message}`); - expect(true).assertFalse(); - console.error('callback release fail'); - done(); - return; - } else { - console.info(`callback call release success `); - expect(true).assertTrue(); - console.info('RELEASE SUCCESS'); - done(); - } - }); //release - }); //stop - }); //start - }); //load - }); - } - - async function recPromise(audioRendererInfo, type, name) { - console.info('AudioFrameworkRecLog recPromise: promise : TonePlayer Function '+ JSON.stringify(name) + ', type: ' + type); - let resultFlag = true; - let tPlayer = null; - await audio.createTonePlayer(audioRendererInfo).then((result) => { - console.info('AudioFrameworkRecLog promise call createTonePlayer-----result: ' + JSON.stringify(result)); - tPlayer = result; - }).catch((err) => { - console.error('promise call createTonePlayer fail tPlayer: '+ tPlayer); - console.error(`promise call createTonePlayer ---fail error. ${err.message}`); - resultFlag = false; - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: createTonePlayer resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.load(type).then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : LOAD SUCCESS'); - console.info('AudioFrameworkRecLog: ---------LOAD---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call load ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: load resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.start().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : START SUCCESS'); - console.info('AudioFrameworkRecLog: ---------START---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call start ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: start resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.stop().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); - console.info('AudioFrameworkRecLog: ---------STOP---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call stop ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: stop resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.release().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : RELEASE SUCCESS'); - console.info('AudioFrameworkRecLog: ---------RELEASE---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call release ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: release resultFlag : ' + resultFlag); - return resultFlag; - } - console.info('promise resultFlag : ' + resultFlag); - return resultFlag; - } - - async function recPromiseStartFail(audioRendererInfo, type, name) { - console.info('recPromiseFail: promise : TonePlayer Function '+ JSON.stringify(name) + ', type: ' + type); - let resultFlag = true; - let tPlayer = null; - console.info('AudioFrameworkRecLog: recPromiseFail : TonePlayer Function ' + JSON.stringify(name)); - await audio.createTonePlayer(audioRendererInfo).then((result) => { - console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); - tPlayer = result; - }).catch((err) => { - console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); - console.error("recPromiseFail call createTonePlayer ---fail"); - resultFlag = false; - }); - if (resultFlag == false) { - console.error('recPromiseFail: createTonePlayer resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.start().then(() => { - console.info('recPromiseFail start TonePlayer : START SUCCESS'); - console.info('recPromiseFail ---------START---------'); - }).catch(() => { - resultFlag = false; - console.error("recPromiseFail call start fail"); - }); - if (resultFlag == false) { - console.error('recPromiseFail resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - resultFlag = false; - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - if (resultFlag == false) { - console.error('recPromiseFail resultFlag : ' + resultFlag); - return resultFlag; - } - console.info('recPromiseFail resultFlag : ' + resultFlag); - return resultFlag; - } - - async function recPromiseLoadStopSuccess(audioRendererInfo, type, name) { - console.info('recPromiseFail: promise : TonePlayer Function '+ JSON.stringify(name) + ', type: ' + type); - let resultFlag = true; - let tPlayer = null; - console.info('AudioFrameworkRecLog: recPromiseFail : TonePlayer Function ' + JSON.stringify(name)); - await audio.createTonePlayer(audioRendererInfo).then((result) => { - console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); - tPlayer = result; - }).catch((err) => { - console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); - console.error("recPromiseFail call createTonePlayer ---fail"); - resultFlag = false; - }); - if (resultFlag == false) { - console.error('recPromiseFail: createTonePlayer resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.load(type).then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : LOAD SUCCESS'); - console.info('AudioFrameworkRecLog: ---------LOAD---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call load ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: load resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.stop().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); - console.info('AudioFrameworkRecLog: ---------STOP---------'); - }).catch((err) => { - resultFlag = false; - console.error(`promise call stop ---fail error. ${err.message}`); - }); - if (resultFlag == false) { - console.error('AudioFrameworkRecLog: stop resultFlag : ' + resultFlag); - return resultFlag; - } - await tPlayer.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - resultFlag = false; - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - if (resultFlag == false) { - console.error('recPromiseFail resultFlag : ' + resultFlag); - return resultFlag; - } - console.info('recPromiseFail resultFlag : ' + resultFlag); - return resultFlag; - } - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_CALLBACK_ALL_0100 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : Callback test case of AudioTonePlayer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_CALLBACK_ALL_0100', 0, async function(done) { - let time1 = (new Date()).getTime(); - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - recCallBack(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_0, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_CALLBACK_ALL_0100', done); - let time2 = (new Date).getTime(); - console.info('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_CALLBACK_ALL_0100 finish time: ' + (time2 - time1)); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_CALLBACK_ALL_0200 - *@tc.name : AudioTonePlayer-create - *@tc.desc : Creation of AudioTonePlayer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_TTONEPLAYER_CALLBACK_ALL_0200', 1, async function(done) { - let time1 = (new Date()).getTime(); - audio.createTonePlayer(null, async (err, data) => { - console.info('SUB_MULTIMEDIA_AUDIO_TTONEPLAYER_CALLBACK_ALL_0200 param is null'); - if (err) { - console.error('callback call createTonePlayer return error:'+ JSON.stringify(err)); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - expect(false).assertFalse(); - done(); - } else { - tonePlayerCallback = data; - expect(true).assertFalse(); - done(); - console.error("callback call createTonePlayer return tonePlayer:" + JSON.stringify(tonePlayerCallback)); - } - console.error("callback create end----------- tonePlayerCallback:" + JSON.stringify(tonePlayerCallback)); - }); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0100 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0100', 1, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_1, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0100'); - console.info('ArecPromise 01 resultFlag : ' + resultFlag); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 01 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0200 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 2 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0200', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_2, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0200'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 02 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0300 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 3 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0300', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_3, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0300'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 03 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0400 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 4 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0400', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_4, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0400'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 04 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0500 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 5 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0500', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_5, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0500'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 05 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0600 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 6 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0600', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_6, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0600'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 06 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0700 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 7 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0700', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_7, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0700'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 07 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0800 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 8 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0800', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_8, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0800'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 08 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0900 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 9 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0900', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_9, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_0900'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 09 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1000 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key * - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1000', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_S, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1000'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 10 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1100 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key # - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1100', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_P, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1100'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 11 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1200 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key A - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1200', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_A, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1200'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 12 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1300 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key B - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1300', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_B, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1300'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 13 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1400 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key C - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1400', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_C, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1400'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 14 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1500 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key D - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1500', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_D, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1500'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 15 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1600 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer Dial Monitoring Tone Promise Success Test Case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1600', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_DIAL, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1600'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 16 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1700 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer Busy Tone Promise Successful Test Case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1700', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_BUSY, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1700'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 17 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1800 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer Congestion Promise Success Test Case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1800', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_CONGESTION, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1800'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 18 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1900 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer Wireless Circuit Path Confirmation Monitoring Tone Promise Success Test Case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1900', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_1900'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 19 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2000 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer radio unavailable promise success test case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2000', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2000'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 20 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2100 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer Call Waiting Promise Success Test Case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2100', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2100'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 21 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2200 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer ring tone promise success test case - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2200', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_SUPERVISORY_RINGTONE, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2200'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 22 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2300 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : Promise success test case of AudioTonePlayer special beep - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2300', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_PROPRIETARY_BEEP, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2300'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 23 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2400 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer positively approves the successful test case of a promise in a proprietary tone - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2400', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_PROPRIETARY_ACK, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2400'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 24 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2500 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : AudioTonePlayer prompts the successful promise test case of the special tone - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2500', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_PROPRIETARY_PROMPT, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2500'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 25 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2600 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : Success Test Case of Promise of AudioTonePlayer Dedicated Double Beep - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2600', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, audio.ToneType.TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2600'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 26 resultFlag : ' + resultFlag); - expect(resultFlag).assertTrue(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2700 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : Promise test case of AudioTonePlayer error parameter - 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2700', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, -1, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2700'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 27 resultFlag : ' + resultFlag); - expect(resultFlag).assertFalse(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2800 - *@tc.name : AudioTonePlayer-create-load-start-stop-release - *@tc.desc : Promise test case with null AudioTonePlayer error parameter - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2800', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromise(audioRendererInfo, null, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2800'); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 28 resultFlag : ' + resultFlag); - expect(resultFlag).assertFalse(); - done(); - }, 1000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2900 - *@tc.name : AudioTonePlayer-create-stop-release fail - *@tc.desc : Test Case for Promise Failure of Dial Tone of AudioTonePlayer Key 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2900', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromiseStartFail(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_1, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_2900'); - console.info('ArecPromise 01 resultFlag : ' + resultFlag); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 29 resultFlag : ' + resultFlag); - expect(resultFlag).assertFalse(); - done(); - }, 2000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_3000 - *@tc.name : AudioTonePlayer-create-load-stop-release fail - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_3000', 2, async function(done) { - let time1 = (new Date()).getTime(); - let resultFlag = false; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - resultFlag = await recPromiseLoadStopSuccess(audioRendererInfo, audio.ToneType.TONE_TYPE_DIAL_1, 'SUB_MULTIMEDIA_AUDIO_TONEPLAYER_PROMISE_ALL_3000'); - console.info('ArecPromise 01 resultFlag : ' + resultFlag); - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - setTimeout(function() { - console.info('AudioFrameworkRenderLog: callback all 30 resultFlag : ' + resultFlag); - expect(resultFlag).assertFalse(); - done(); - }, 2000) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100 - *@tc.name : AudioTonePlayer-create - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100', 2, function(done) { - audio.createTonePlayer(stringParameter).then(async (result) => { - console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); - await result.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - expect(false).assertTrue(); - }).catch((err) => { - console.log('err :' + err.code) - if (err.code == 6800101) { - console.log(`${TagTone}: load : PASS : message:${err.message}`); - expect(true).assertTrue(); - }else { - console.log(`${TagTone}: load : FAIL : message:${err.message}`); - expect(false).assertTrue(); - } - }); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100 - *@tc.name : AudioTonePlayer-create - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0200', 2, function(done) { - audio.createTonePlayer(stringParameter, async (err, data)=>{ - if (err) { - console.log('err :' + err.code) - if (err.code == 6800101) { - console.log(`${TagTone}: load : PASS : message:${err.message}`); - expect(true).assertTrue(); - }else { - console.log(`${TagTone}: load : FAIL : message:${err.message}`); - expect(false).assertTrue(); - } - } else { - await data.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - expect(false).assertTrue(); - } - done(); - }) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100 - *@tc.name : AudioTonePlayer-create-load-stop-release success - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100', 2, async function(done) { - let tPlayer = null; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - await audio.createTonePlayer(audioRendererInfo).then((result) => { - console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); - tPlayer = result; - }).catch((err) => { - console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); - console.error("recPromiseFail call createTonePlayer ---fail"); - }); - - await tPlayer.load(stringParameter).then(() => { - console.info('AudioFrameworkRecLog: ---------LOAD---------'); - expect(false).assertTrue(); - }).catch((err) => { - console.log('err :' + err.code) - if (err.code == 6800101) { - console.log(`${TagTone}: load : PASS : message:${err.message}`); - expect(true).assertTrue(); - }else { - console.log(`${TagTone}: load : FAIL : message:${err.message}`); - expect(false).assertTrue(); - } - }); - - await tPlayer.stop().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); - console.info('AudioFrameworkRecLog: ---------STOP---------'); - }).catch((err) => { - console.error(`promise call stop ---fail error. ${err.message}`); - }); - - await tPlayer.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200 - *@tc.name : AudioTonePlayer-create-load-stop-release success - *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200', 2, async function(done) { - let time1 = (new Date()).getTime(); - let tPlayer = null; - let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 - } - - await audio.createTonePlayer(audioRendererInfo).then((result) => { - console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); - tPlayer = result; - }).catch((err) => { - console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); - console.error("recPromiseFail call createTonePlayer ---fail"); - }); - - await tPlayer.load(stringParameter, (err, data)=>{ - if (err) { - console.log('err :' + err.code) - if (err.code == 6800101) { - console.log(`${TagTone}: load : PASS : message:${err.message}`); - expect(true).assertTrue(); - }else { - console.log(`${TagTone}: load : FAIL : message:${err.message}`); - expect(false).assertTrue(); - } - } else { - console.info('AudioFrameworkRecLog: ---------LOAD---------'); - expect(false).assertTrue(); - } - }); - await sleep(1000); - await tPlayer.stop().then(() => { - console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); - console.info('AudioFrameworkRecLog: ---------STOP---------'); - }).catch((err) => { - console.error(`promise call stop ---fail error. ${err.message}`); - }); - - await tPlayer.release().then(() => { - console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); - console.info('recPromiseFail ---------RELEASE---------'); - }).catch((err) => { - console.error("recPromiseFail call release fail " + JSON.stringify(err)); - }); - - let time2 = (new Date).getTime(); - console.info('time: ' + (time2 - time1)); - done(); - }) -}) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/List.test.js deleted file mode 100644 index 9ade1eab8c7ba3f12e4aa93d390bb1c6a36471f2..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/List.test.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (C) 2022 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. - */ - -require('./AudioTonePlayer.test.js') - - diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/element/string.json deleted file mode 100644 index 0bae6bd40f7360d5d818998221b199d3ec0f69c0..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/common.js b/multimedia/userfilemgr/common.js deleted file mode 100755 index 6b56777a02d3b6e45f9843562a869f826634eaf4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/common.js +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundle from '@ohos.bundle'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -const presetsCount = { - ActsUserFileMgrAlbumJsTest: { albumsCount: 3, assetsCount: 3 }, - ActsUserFileMgrBaseJsTest: { albumsCount: 18, assetsCount: 33 }, - ActsUserFileMgrFileAssetJsTest: { albumsCount: 45, assetsCount: 87 }, -} - -const IMAGE_TYPE = userFileManager.FileType.IMAGE; -const VIDEO_TYPE = userFileManager.FileType.VIDEO; -const AUDIO_TYPE = userFileManager.FileType.AUDIO; - -const AUDIOKEY = userFileManager.AudioKey; -const IMAGEVIDEOKEY = userFileManager.ImageVideoKey; -const ALBUMKEY = userFileManager.AlbumKey; -const THROW_ERROR_CODE = 13900020; -const sleep = async function sleep(times) { - if (times == undefined) { - times = 10 - } - await new Promise(res => setTimeout(res, times)); -} - -const allFetchOp = function () { - let predicates = new dataSharePredicates.DataSharePredicates(); - return { - fetchColumns: [], - predicates: predicates - }; -} - -const audioFetchOps = function (testNum, path) { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo("relative_path", path); - let ops = { - fetchColumns: [], - predicates: predicates - }; - console.info(`${testNum} queryOps: relative_path = ${path}`); - return ops -} - -const imageVideoFetchOps = function (testNum, path) { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo("relative_path", path); - let ops = { - fetchColumns: [], - predicates: predicates - }; - console.info(`${testNum} queryOps: relative_path = ${path}`); - return ops -} - -const audioNameFetchOps = function (testNum, path, displayName) { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo("relative_path", path) - .equalTo(AUDIOKEY.DISPLAY_NAME, displayName); - let ops = { - fetchColumns: [], - predicates: predicates - }; - console.info(`${testNum} queryOps: relative_path = ${path} AND display_name = ${displayName}`); - return ops -} - -const imageVideoNameFetchOps = function (testNum, path, displayName) { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo("relative_path", path) - .equalTo(IMAGEVIDEOKEY.DISPLAY_NAME, displayName); - let ops = { - fetchColumns: [], - predicates: predicates - }; - console.info(`${testNum} queryOps: relative_path = ${path} AND display_name = ${displayName}`); - return ops -} - -const albumFetchOps = function (testNum, path, albumName) { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo("relative_path", path) - .equalTo(ALBUMKEY.ALBUM_NAME, albumName); - let ops = { - predicates: predicates - }; - console.info(`${testNum} queryOps: relative_path = ${path} AND bucket_display_name = ${albumName}`); - return ops -} - -const checkPresetsAssets = async function (userfilemgr, hapName) { - console.info('checkPresetsAssets start') - let fetchAlbumResult = await userfilemgr.getPhotoAlbums(allFetchOp()); - let albumsCount = fetchAlbumResult.getCount(); - let fetchPhotoResult = await userfilemgr.getPhotoAssets(allFetchOp()); - let fetchAudioResult = await userfilemgr.getAudioAssets(allFetchOp()); - let assetsCount = fetchPhotoResult.getCount() + fetchAudioResult.getCount(); - console.info(`${hapName}:: assetsCount: ${assetsCount} albumsCount: ${albumsCount}, - presetsassetsCount: ${presetsCount[hapName].assetsCount} - presetsalbumsCount: ${presetsCount[hapName].albumsCount}`); - console.info('checkPresetsAssets end') -} - -const checkAssetsCount = async function (done, testNum, fetchAssetResult, expectCount) { - if (!fetchAssetResult) { - console.info(`${testNum}:: fetchAssetResult is undefined`); - expect(false).assertTrue(); - done(); - return false - } - let count = await fetchAssetResult.getCount(); - if (count != expectCount) { - console.info(`${testNum}:: count:expectCount - ${count} : ${expectCount}`); - expect(count).assertEqual(expectCount); - done(); - } - return count == expectCount; -} - -const getPermission = async function (name = 'ohos.acts.multimedia.userfilemgr') { - console.info('getPermission start', name) - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.userfilemgr', 0, 100); - let tokenID = appInfo.accessTokenId; - let atManager = abilityAccessCtrl.createAtManager(); - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION", 1); - } catch (error) { - console.info('getPermission MEDIA_LOCATION failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_IMAGEVIDEO", 1); - } catch (error) { - console.info('getPermission READ_IMAGEVIDEO failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_AUDIO", 1); - } catch (error) { - console.info('getPermission READ_AUDIO failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_DOCUMENT", 1); - } catch (error) { - console.info('getPermission READ_DOCUMENT failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_IMAGEVIDEO", 1); - } catch (error) { - console.info('getPermission WRITE_IMAGEVIDEO failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_AUDIO", 1); - } catch (error) { - console.info('getPermission WRITE_AUDIO failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_DOCUMENT", 1); - } catch (error) { - console.info('getPermission WRITE_DOCUMENT failed') - } - let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION"); - let isGrantedReadImageVideo = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_IMAGEVIDEO"); - let isGrantedReadAudio = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_AUDIO"); - let isGrantedReadDocument = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_DOCUMENT"); - let isGrantedWriteImageVideo = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_IMAGEVIDEO"); - let isGrantedWriteAudio = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_AUDIO"); - let isGrantedWriteDocument = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_DOCUMENT"); - if (isGranted1 !=0 || - !(isGrantedReadImageVideo == 0 && isGrantedReadAudio == 0 && isGrantedReadDocument == 0) || - !(isGrantedWriteImageVideo == 0 && isGrantedWriteAudio == 0 && isGrantedWriteDocument == 0)) { - console.info('getPermission failed') - } - console.info('getPermission end') -} - -const isNum = function (value) { - return typeof value === 'number' && !isNaN(value); -} -export { - getPermission, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - THROW_ERROR_CODE, - sleep, - allFetchOp, - audioFetchOps, - imageVideoFetchOps, - audioNameFetchOps, - imageVideoNameFetchOps, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, - isNum, -}; \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/AppScope/app.json b/multimedia/userfilemgr/userfilemgr_album/AppScope/app.json deleted file mode 100755 index 103cf8e6368fd2a71f15ca4506e1ce4e48a58669..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.userfilemgr", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} diff --git a/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/element/string.json deleted file mode 100755 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/media/app_icon.png b/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/media/app_icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_album/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_album/BUILD.gn b/multimedia/userfilemgr/userfilemgr_album/BUILD.gn deleted file mode 100755 index c2d6356fa83ce43f2612672796b5b1c50fb86b88..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/BUILD.gn +++ /dev/null @@ -1,40 +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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("userfilemgr_album_js_hap") { - hap_profile = "entry/src/main/module.json" - deps = [ - ":mediaLibrary_js_assets", - ":mediaLibrary_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "ActsUserFileMgrAlbumJsTest" -} - -ohos_app_scope("medialibrary_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_js_assets("mediaLibrary_js_assets") { - source_dir = "entry/src/main/ets" -} - -ohos_resources("mediaLibrary_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":medialibrary_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/multimedia/userfilemgr/userfilemgr_album/Test.json b/multimedia/userfilemgr/userfilemgr_album/Test.json deleted file mode 100755 index 7fd3542fa9a804055248f80583c10576041a2775..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/Test.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "description": "Configuration for userfilemgr Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.userfilemgr", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/Pictures", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/{Static,DynamicCb,DynamicPro}", - - "for d in Static DynamicCb DynamicPro; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsUserFileMgrAlbumJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100755 index 14f230e140160dc5f94ecc462304621178f4cf64..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100755 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/index/index.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index ac301f98781abd45f4d9d98fd7ffecfde9053ed9..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +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 file from '@system.file'; - -import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/second/second.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +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 router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/List.test.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/List.test.ets deleted file mode 100755 index 3eb3b9f14c2b370bf89120b391eb435ea36ccca1..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/List.test.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 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 albumCommitModifyCallback from './albumCommitModifyCallback.test.ets' -import albumCommitModifyPromise from './albumCommitModifyPromise.test.ets' -import albumGetFileAssetsCallback from './albumGetFileAssetsCallback.test.ets' -import albumGetFileAssetsPromise from './albumGetFileAssetsPromise.test.ets' -export default function testsuite(abilityContext) { - albumCommitModifyCallback(abilityContext) - albumCommitModifyPromise(abilityContext) - albumGetFileAssetsCallback(abilityContext) - albumGetFileAssetsPromise(abilityContext) -} diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyCallback.test.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyCallback.test.ets deleted file mode 100755 index 4e8fe7492da8c3d0279fd18331ba65f00981eae7..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyCallback.test.ets +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -import { - sleep, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, - getPermission, -} from '../../../../../../common'; - - -export default function albumCommitModifyCallback(abilityContext) { - describe('albumCommitModifyCallback', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const albumCommitModify = async function (done, testNum, fetchOp, expectAlbumCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - const oldName = album.albumName; - const albumUri = album.albumUri; - const newName = 'newAlbumNameCallback'; - fetchAlbumResult.close(); - album.albumName = newName; - album.commitModify(async () => { - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(userFileManager.AlbumKey.URI.toString(), albumUri); - let ops = { - predicates: predicates - }; - const newResult = await userfilemgr.getPhotoAlbums(ops); - const albumCountPass = await checkAssetsCount(done, testNum, newResult, expectAlbumCount); - if (!albumCountPass) return; - const newAlbum = await newResult.getFirstObject(); - expect(newAlbum.albumName).assertEqual(newName); - newAlbum.albumName = oldName; - await newAlbum.commitModify(); - done(); - }); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01 - * @tc.name : commitModify - * @tc.desc : image album modify albumname - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01', 2, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb'); - await albumCommitModify(done, testNum, currentFetchOp); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyPromise.test.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyPromise.test.ets deleted file mode 100755 index a71a82e05c7541348a0cd0fc3172c5b39d48e391..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumCommitModifyPromise.test.ets +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -import { - sleep, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, - getPermission, -} from '../../../../../../common'; - - -export default function albumCommitModifyPromise(abilityContext) { - describe('albumCommitModifyPromise', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const albumCommitModify = async function (done, testNum, fetchOp, expectAlbumCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - const oldName = album.albumName; - const albumUri = album.albumUri; - const newName = 'newAlbumNamePromise'; - fetchAlbumResult.close(); - album.albumName = newName; - await album.commitModify(); - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(userFileManager.AlbumKey.URI.toString(), albumUri); - let ops = { - predicates: predicates - }; - const newResult = await userfilemgr.getPhotoAlbums(ops); - const checkAlbumCountPass = await checkAssetsCount(done, testNum, newResult, expectAlbumCount); - if (!checkAlbumCountPass) return; - const newAlbum = await newResult.getFirstObject(); - expect(newAlbum.albumName).assertEqual(newName); - newAlbum.albumName = oldName; - await newAlbum.commitModify(); - done(); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01 - * @tc.name : commitModify - * @tc.desc : album modify albumname - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01', 2, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro'); - await albumCommitModify(done, testNum, currentFetchOp); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets deleted file mode 100755 index 570bc3d7f37a15c9a7d23c9880658dd53457f628..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - THROW_ERROR_CODE, - allFetchOp, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - -export default function albumGetFileAssetsCallback(abilityContext) { - describe('albumGetFileAssetsCallback', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const getPhotoAssetsTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - fetchAlbumResult.close(); - album.getPhotoAssets(allFetchOp(), (error, fetchAssetResult) => { - if (error != undefined) { - console.info(`${testNum} getPhotoAssets error: ${error}`); - expect(false).assertTrue(); - done(); - return; - } - console.info(`${testNum}, getCount: ${fetchAssetResult.getCount()} - expectAssetsCount: ${expectAssetsCount}`); - expect(fetchAssetResult.getCount()).assertEqual(expectAssetsCount); - fetchAssetResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}, error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - fetchAlbumResult.close(); - let invalidOps : userFileManager.FetchOptions; - album.getPhotoAssets(invalidOps, (error, fetchAssetResult) => { - if (error != undefined) { - console.info(`${testNum} getPhotoAssetsErrCodeTest error: ${error}`); - expect(false).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - fetchAssetResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}, errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : Album getPhotoAssets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static'); - await getPhotoAssetsTest(done, testNum, currentFetchOp); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : invalid AlbumFetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 3, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static'); - await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp); - }); - }); -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets deleted file mode 100755 index 33f6d71d94e32410803c8ed33e3eacc181f77384..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - THROW_ERROR_CODE, - allFetchOp, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - -export default function albumGetFileAssetsPromise(abilityContext) { - describe('albumGetFileAssetsPromise', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const getPhotoAssetsTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - fetchAlbumResult.close(); - let op: userFileManager.FetchOptions = allFetchOp(); - let fetchAssetResult = await album.getPhotoAssets(op); - if (fetchAssetResult == undefined) { - expect(false).assertTrue(); - done(); - return; - } - console.info(`${testNum}, getCount: ${fetchAssetResult.getCount()} - expectAssetsCount: ${expectAssetsCount}`) - expect(fetchAssetResult.getCount()).assertEqual(expectAssetsCount); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}, error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - fetchAlbumResult.close(); - let invalidOps : userFileManager.FetchOptions; - let fetchAssetResult = await album.getPhotoAssets(invalidOps); - expect(false).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}, errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01 - * @tc.name : getPhotoAssets - * @tc.desc : Album getPhotoAssets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static'); - await getPhotoAssetsTest(done, testNum, currentFetchOp); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01 - * @tc.name : getPhotoAssets - * @tc.desc : invalid AlbumFetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 3, async function (done) { - const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static'); - await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp); - }); - }); -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/module.json b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/module.json deleted file mode 100755 index 0bb8c230ed6bce84005fc4df0d8651857e2452c9..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/module.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.userfilemgr.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/element/string.json deleted file mode 100755 index 32237ee203edf64926964fb238fa44e396ddf577..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/media/icon.png b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/profile/main_pages.json b/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 96b478210df9884592229ae2db6f6bb7f86c14f4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_album/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_album/signature/openharmony_sx.p7b b/multimedia/userfilemgr/userfilemgr_album/signature/openharmony_sx.p7b deleted file mode 100755 index 66b4457a8a81fb8d3356cf46d67226c850944858..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_album/signature/openharmony_sx.p7b and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_base/AppScope/app.json b/multimedia/userfilemgr/userfilemgr_base/AppScope/app.json deleted file mode 100755 index 25f1a749f8b57b96979879112a1f5bd21548a92c..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.userfilemgr", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} diff --git a/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/element/string.json deleted file mode 100755 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/media/app_icon.png b/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/media/app_icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_base/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_base/BUILD.gn b/multimedia/userfilemgr/userfilemgr_base/BUILD.gn deleted file mode 100755 index 0bdbd5796205af9f91f30776113530ec1d393a2d..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/BUILD.gn +++ /dev/null @@ -1,40 +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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("userfilemgr_base_js_hap") { - hap_profile = "entry/src/main/module.json" - deps = [ - ":mediaLibrary_js_assets", - ":mediaLibrary_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "ActsUserFileMgrBaseJsTest" -} - -ohos_app_scope("medialibrary_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_js_assets("mediaLibrary_js_assets") { - source_dir = "entry/src/main/ets" -} - -ohos_resources("mediaLibrary_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":medialibrary_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/multimedia/userfilemgr/userfilemgr_base/Test.json b/multimedia/userfilemgr/userfilemgr_base/Test.json deleted file mode 100755 index 0d8d52de9d83ec1865ddab478f84153bc420dfdf..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/Test.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "description": "Configuration for userfilemgr Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.userfilemgr", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/{Static,onAsset,offAsset,onAlbum,offAlbum,myAlbum,deleteCb,deletePro}", - "mkdir -pv /storage/media/100/local/files/Videos/{Static,onAsset,offAsset,onAlbum,offAlbum,myAlbum,deleteCb,deletePro}", - "mkdir -pv /storage/media/100/local/files/Audios/{Static,onAsset,offAsset,onAlbum,offAlbum,myAlbum,deleteCb,deletePro}", - - "for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - "for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - "for d in onAsset offAsset onAlbum offAlbum myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in onAsset offAsset onAlbum offAlbum myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in onAsset offAsset onAlbum offAlbum myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsUserFileMgrBaseJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100755 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100755 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/index/index.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 624cad290665fcd29dcd579d9582a300479e8ad7..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,68 +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 file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/second/second.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +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 router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/List.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/List.test.ets deleted file mode 100755 index 0fc8409e41b0ce5fd3b3e2201fee0b7a196192a8..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/List.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022 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 deleteCallbackTest from './deleteCallback.test.ets' -import deletePromiseTest from './deletePromise.test.ets' -import getAlbumsCallbackTest from './getAlbumsCallback.test.ets' -import getAlbumsPromiseTest from './getAlbumsPromise.test.ets' -import getFileAssetsCallbackTest from './getFileAssetsCallback.test.ets' -import getFileAssetsPromiseTest from './getFileAssetsPromise.test.ets' -import getUserFileMgrTest from './getUserFileMgr.test.ets' -import onOffReleasePromiseTest from './onOffReleasePromise.test.ets' -export default function testsuite(abilityContext) { - deleteCallbackTest(abilityContext) - deletePromiseTest(abilityContext) - getAlbumsCallbackTest(abilityContext) - getAlbumsPromiseTest(abilityContext) - getFileAssetsCallbackTest(abilityContext) - getFileAssetsPromiseTest(abilityContext) - getUserFileMgrTest(abilityContext) - onOffReleasePromiseTest(abilityContext) -} diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deleteCallback.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deleteCallback.test.ets deleted file mode 100644 index 3c523b5548ac9dc46d2ecfade523b37c854fa1f2..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deleteCallback.test.ets +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - audioFetchOps, - imageVideoFetchOps, - checkPresetsAssets, - checkAssetsCount, - getPermission, -} from '../../../../../../common'; - - -export default function deleteCallbackTest(abilityContext) { - describe('deleteCallbackTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const deleteTest = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 2; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - userfilemgr.delete(asset.uri, async() => { - let newFetchResult; - if (isAudio) { - newFetchResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - newFetchResult = await userfilemgr.getPhotoAssets(fetchOp); - } - expect(newFetchResult.getCount()).assertEqual(1); - newFetchResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}, failed: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_01 - * @tc.name : delete - * @tc.desc : delete image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_01'; - let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deleteCb/'); - let isAudio = false; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_02 - * @tc.name : delete - * @tc.desc : delete video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_02'; - let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deleteCb/'); - let isAudio = false; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_03 - * @tc.name : delete - * @tc.desc : delete audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_03'; - let currentFetchOp = audioFetchOps(testNum, 'Audios/deleteCb/'); - let isAudio = true; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deletePromise.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deletePromise.test.ets deleted file mode 100644 index 71f3dcd6d762ee407faa434a6b285bd4188bab01..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/deletePromise.test.ets +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - audioFetchOps, - imageVideoFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - - -export default function deletePromiseTest(abilityContext) { - describe('deletePromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const deleteTest = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 2; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - await userfilemgr.delete(asset.uri); - let newFetchResult; - if (isAudio) { - newFetchResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - newFetchResult = await userfilemgr.getPhotoAssets(fetchOp); - } - expect(newFetchResult.getCount()).assertEqual(1); - newFetchResult.close(); - done(); - } catch (error) { - console.info(`${testNum}, failed: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_01 - * @tc.name : delete - * @tc.desc : delete image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_01'; - let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deletePro/'); - let isAudio = false; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_02 - * @tc.name : delete - * @tc.desc : delete video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_02'; - let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deletePro/'); - let isAudio = false; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_03 - * @tc.name : delete - * @tc.desc : delete audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_DELETE_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_03'; - let currentFetchOp = audioFetchOps(testNum, 'Audios/deletePro/'); - let isAudio = true; - await deleteTest(done, testNum, currentFetchOp, isAudio); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsCallback.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsCallback.test.ets deleted file mode 100644 index 7b9d66e7e57c37922a728717b23b4993dedcd9de..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsCallback.test.ets +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - THROW_ERROR_CODE, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, - isNum, -} from '../../../../../../common'; - - -export default function getAlbumsCallbackTest(abilityContext) { - describe('getAlbumsCallbackTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - function printAlbumMessage(testNum, album) { - console.info(`${testNum} - album.albumName: ${album.albumName} - album.albumUri: ${album.albumUri} - album.dateModified: ${album.dateModified} - album.count: ${album.count} - album.relativePath: ${album.relativePath} - album.coverUri: ${album.coverUri}`); - } - - const props = { - albumName: 'myAlbum', - albumUri: 'datashare:///userfilemgr/album/', - count: 1 - } - const checkProps = async function (done, testNum, album, relativePaths) { - printAlbumMessage(testNum, album); - if (album.coverUri == undefined) { - console.info(`${testNum}, album.coverUri is undefined`); - expect(false).assertTrue(); - done(); - return; - } - expect(album.albumName).assertEqual(props.albumName); - expect(album.count).assertEqual(props.count); - expect(isNum(album.dateModified)).assertTrue(); - if (Array.isArray(relativePaths)) { - let i = relativePaths.indexOf(album.relativePath); - if (i > -1) { - relativePaths.splice(i, 1) - } else { - expect(false).assertTrue(); - done(); - } - } else { - expect(album.relativePath).assertEqual(relativePaths); - } - } - const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths) { - try { - userfilemgr.getPhotoAlbums(fetchOp, async (err, fetchAlbumResult) => { - if(err) { - console.info(`${testNum} getPhotoAlbums err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - let expectAlbumCount = 1; - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - checkProps(done, testNum, album, relativePaths); - fetchAlbumResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}, failed: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAlbumsErrCodeTest = async function (done, testNum) { - try { - let invalidOps : userFileManager.FetchOptions; - userfilemgr.getPhotoAlbums(invalidOps, async (err, fetchAlbumResult) => { - if(err) { - console.info(`${testNum} getPhotoAlbums err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - fetchAlbumResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}, errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum'); - let relativePaths = 'Pictures/'; - await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums by invalid - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01'; - await getPhotoAlbumsErrCodeTest(done, testNum); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets deleted file mode 100644 index 2e6733aa1543840a722a0cd22b8a3621a20e0a13..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - THROW_ERROR_CODE, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - -export default function getAlbumsPromiseTest(abilityContext) { - describe('getAlbumsPromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - function printAlbumMessage(testNum, album) { - console.info(`${testNum} - album.albumName: ${album.albumName} - album.albumUri: ${album.albumUri} - album.dateModified: ${album.dateModified} - album.count: ${album.count} - album.relativePath: ${album.relativePath} - album.coverUri: ${album.coverUri}`); - } - - const props = { - albumName: 'myAlbum', - albumUri: 'datashare:///userfilemgr/album/', - count: 1 - } - const checkProps = async function (done, testNum, album, relativePaths) { - printAlbumMessage(testNum, album); - if (album.coverUri == undefined) { - console.info(`${testNum}, album.coverUri is undefined`); - expect(false).assertTrue(); - done(); - return; - } - expect(album.albumName).assertEqual(props.albumName); - expect(album.count).assertEqual(props.count); - if (Array.isArray(relativePaths)) { - let i = relativePaths.indexOf(album.relativePath); - if (i > -1) { - relativePaths.splice(i, 1) - } else { - expect(false).assertTrue(); - done(); - } - } else { - expect(album.relativePath).assertEqual(relativePaths); - } - } - const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths, expectAlbumCount = 1) { - try { - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp); - const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); - if (!albumCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - checkProps(done, testNum, album, relativePaths); - fetchAlbumResult.close(); - done(); - } catch (error) { - console.info(`${testNum}, failed: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAlbumsErrCodeTest = async function (done, testNum) { - try { - let invalidOps : userFileManager.FetchOptions; - let fetchAlbumResult = await userfilemgr.getPhotoAlbums(invalidOps); - expect(false).assertTrue(); - fetchAlbumResult.close(); - done(); - } catch (error) { - console.info(`${testNum}, errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum'); - let relativePaths = 'Pictures/'; - await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums by invalid - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01'; - await getPhotoAlbumsErrCodeTest(done, testNum); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsCallback.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsCallback.test.ets deleted file mode 100644 index bceebef1d98c2e8e6512d288a9d8bea3b2af021f..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsCallback.test.ets +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - THROW_ERROR_CODE, - audioFetchOps, - imageVideoFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - - -export default function getFileAssetsCallbackTest(abilityContext) { - describe('getFileAssetsCallbackTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrBaseJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep(500) - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const props = { - image: { - displayName: '01.jpg', - fileType: IMAGE_TYPE.toString(), - }, - video: { - displayName: '01.mp4', - fileType: VIDEO_TYPE.toString(), - }, - audio: { - displayName: '01.mp3', - fileType: AUDIO_TYPE.toString(), - }, - } - - async function getFirstObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - fetchAssetResult.getFirstObject(async (err, asset) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - fetchAssetResult.close(); - done(); - return; - } - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - }); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getNextObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - await fetchAssetResult.getFirstObject(); - fetchAssetResult.getNextObject(async (err, asset) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - fetchAssetResult.close(); - done(); - return; - } - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - }); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getLastObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - fetchAssetResult.getLastObject(async (err, asset) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - fetchAssetResult.close(); - done(); - return; - } - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - }); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getPositionObjectTest(done, testNum, fetchOp, pos, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - fetchAssetResult.getPositionObject(pos, async (err, asset) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - fetchAssetResult.close(); - done(); - return; - } - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - }); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function isAfterLastTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - for (var i = 1; i < expectCount; i++) { - asset = await fetchAssetResult.getNextObject(); - if (i == expectCount - 1) { - let result = fetchAssetResult.isAfterLast(); - expect(result).assertTrue(); - fetchAssetResult.close(); - done(); - } - } - done(); - } catch (error) { - console.info(`${testNum} error ${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function fetchResultCloseTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - fetchAssetResult.close(); - let count = 0; - try { - fetchAssetResult.getCount(); - } catch { count++ } - try { - await fetchAssetResult.getFirstObject(); - } catch { count++ } - try { - await fetchAssetResult.getNextObject(); - } catch { count++ } - try { - await fetchAssetResult.getLastObject(); - } catch { count++ } - try { - await fetchAssetResult.getPositionObject(0); - } catch { count++ } - await sleep(1000) - expect(count).assertEqual(5); - done(); - } catch (error) { - console.info(`${testNum} error ${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function checkFileAssetAttr(done, testNum, fetchOp, type, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - fetchAssetResult.getFirstObject((err, asset) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - fetchAssetResult.close(); - done(); - return; - } - expect(asset.displayName).assertEqual(props[type].displayName); - expect(asset.fileType.toString()).assertEqual(props[type].fileType); - expect(asset.uri != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getFileAssetsErrCodeTest(done, testNum, isAudio) { - try { - let invalidOps : userFileManager.FetchOptions; - if (isAudio) { - await userfilemgr.getAudioAssets(invalidOps, (err, fetchAssetResult) => { - if (err != undefined) { - console.info(`${testNum}:: getAudioAssets error :${err}`); - expect(false).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } else { - await userfilemgr.getPhotoAssets(invalidOps, (err, fetchAssetResult) => { - if (err != undefined) { - console.info(`${testNum}:: getAudioAssets error :${err}`); - expect(false).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } - } catch (error) { - console.info(`${testNum}:: errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_01 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_02 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_03 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_01 - * @tc.name : getNextObject - * @tc.desc : getNextObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_02 - * @tc.name : getNextObject - * @tc.desc : getNextObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_03 - * @tc.name : getNextObject - * @tc.desc : getNextObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_01 - * @tc.name : getLastObject - * @tc.desc : getLastObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_02 - * @tc.name : getLastObject - * @tc.desc : getLastObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_03 - * @tc.name : getLastObject - * @tc.desc : getLastObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_01 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let pos = 0; - let isAudio = false; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_02 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let pos = 0; - let isAudio = false; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_03 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let pos = 0; - let isAudio = true; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - //----------------------------------------------------------------------------------- - - /** - * @tc.number : SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_01 - * @tc.name : isAfterLast - * @tc.desc : isAfterLast query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await isAfterLastTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_02 - * @tc.name : isAfterLast - * @tc.desc : isAfterLast query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await isAfterLastTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_03 - * @tc.name : isAfterLast - * @tc.desc : isAfterLast query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ISAFTERLAST_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await isAfterLastTest(done, testNum, currentFetchOps, isAudio); - }); - - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_01 - * @tc.name : close - * @tc.desc : when fetchResult close,fetchResult getAsset is undefined? - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await fetchResultCloseTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_02 - * @tc.name : close - * @tc.desc : when fetchResult close,fetchResult getAsset is undefined? - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await fetchResultCloseTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_03 - * @tc.name : close - * @tc.desc : when fetchResult close,fetchResult getAsset is undefined? - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FETCHRESULT_CLOSE_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await fetchResultCloseTest(done, testNum, currentFetchOps, isAudio); - }); - - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_01', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let type = 'image'; - let isAudio = false; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_02 - * @tc.name : getPhotoAssets - * @tc.desc : query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_02', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let type = 'video'; - let isAudio = false; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_03 - * @tc.name : getAudioAssets - * @tc.desc : query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_03', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let type = 'audio'; - let isAudio = true; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : invalid FetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01'; - let isAudio = false; - await getFileAssetsErrCodeTest(done, testNum, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_ERRCODE_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : invalid FetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETS_ERRCODE_CALLBACK_01', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_ERRCODE_CALLBACK_01'; - let isAudio = true; - await getFileAssetsErrCodeTest(done, testNum, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsPromise.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsPromise.test.ets deleted file mode 100644 index b4c608ee6ab216d2310c8fdaa92287eae9334800..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsPromise.test.ets +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - THROW_ERROR_CODE, - checkPresetsAssets, - checkAssetsCount, - audioFetchOps, - imageVideoFetchOps, -} from '../../../../../../common'; - - -export default function getFileAssetsPromiseTest(abilityContext) { - describe('getFileAssetsPromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrBaseJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep(500) - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const props = { - image: { - displayName: '01.jpg', - fileType: IMAGE_TYPE.toString(), - }, - video: { - displayName: '01.mp4', - fileType: VIDEO_TYPE.toString(), - }, - audio: { - displayName: '01.mp3', - fileType: AUDIO_TYPE.toString(), - }, - } - - async function getFirstObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getNextObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - await fetchAssetResult.getFirstObject(); - let asset = await fetchAssetResult.getNextObject(); - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getLastObjectTest(done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getLastObject(); - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getPositionObjectTest(done, testNum, fetchOp, pos, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getPositionObject(pos); - expect(asset != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function checkFileAssetAttr(done, testNum, fetchOp, type, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let expectCount = 4; - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - expect(asset.displayName).assertEqual(props[type].displayName); - expect(asset.fileType.toString()).assertEqual(props[type].fileType); - expect(asset.uri != undefined).assertTrue(); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getFileAssetsErrCodeTest(done, testNum, isAudio) { - try { - let invalidOps : userFileManager.FetchOptions; - if (isAudio) { - await userfilemgr.getAudioAssets(invalidOps); - } else { - await userfilemgr.getPhotoAssets(invalidOps); - } - expect(false).assertTrue(); - } catch (error) { - console.info(`${testNum}:: errCode :${JSON.stringify(error)}`); - expect(error.code).assertEqual(THROW_ERROR_CODE.toString()); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_01 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_02 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_03 - * @tc.name : getFirstObject - * @tc.desc : getFirstObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETFIRSTOBJECT_PROMISE_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getFirstObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_01 - * @tc.name : getNextObject - * @tc.desc : getNextObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_02 - * @tc.name : getNextObject - * @tc.desc : getNextObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_03 - * @tc.name : getNextObject - * @tc.desc : getNextObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETNEXTOBJECT_PROMISE_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getNextObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_01 - * @tc.name : getLastObject - * @tc.desc : getLastObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let isAudio = false; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_02 - * @tc.name : getLastObject - * @tc.desc : getLastObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let isAudio = false; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_03 - * @tc.name : getLastObject - * @tc.desc : getLastObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETLASTOBJECT_PROMISE_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let isAudio = true; - await getLastObjectTest(done, testNum, currentFetchOps, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_01 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let pos = 0; - let isAudio = false; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_02 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let pos = 0; - let isAudio = false; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_03 - * @tc.name : getPositionObject - * @tc.desc : getPositionObject query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_PROMISE_03'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let pos = 0; - let isAudio = true; - await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio); - }); - - //--------------------------------------------------------------------------------- - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_01 - * @tc.name : getPhotoAssets - * @tc.desc : query image assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_01', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_01'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); - let type = 'image'; - let isAudio = false; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_02 - * @tc.name : getPhotoAssets - * @tc.desc : query video assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_02', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_02'; - let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Static/'); - let type = 'video'; - let isAudio = false; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_PROMISE_01 - * @tc.name : getAudioAssets - * @tc.desc : query audio assets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETS_PROMISE_01', 1, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_PROMISE_01'; - let currentFetchOps = audioFetchOps(testNum, 'Audios/Static/'); - let type = 'audio'; - let isAudio = true; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01 - * @tc.name : getPhotoAssets - * @tc.desc : invalid FetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01'; - let isAudio = false; - await getFileAssetsErrCodeTest(done, testNum, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02 - * @tc.name : getPhotoAssets - * @tc.desc : invalid FetchOptions - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02', 3, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02'; - let isAudio = true; - await getFileAssetsErrCodeTest(done, testNum, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getUserFileMgr.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getUserFileMgr.test.ets deleted file mode 100644 index c1bdde255f71cd8360d038e74268b7465d16d5b4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getUserFileMgr.test.ets +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { sleep } from '../../../../../../common'; - -export default function getUserFileMgrTest(abilityContext) { - describe('getUserFileMgrTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETUSERFILEMGR_00 - * @tc.name : getUserFileMgr - * @tc.desc : Obtains a userFileMgr instance - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_USERFILE_MGR_GETUSERFILEMGR_00', 0, async function (done) { - try { - expect(userfilemgr != undefined).assertTrue(); - done(); - } catch (error) { - console.info(`SUB_USERFILE_MGR_GETUSERFILEMGR_00 failed, error: ${error}`); - expect(false).assertTrue(); - done(); - } - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/onOffReleasePromise.test.ets b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/onOffReleasePromise.test.ets deleted file mode 100644 index 7f39f083e2fe3c65f3e9add85b9936d312ee9271..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/onOffReleasePromise.test.ets +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - audioNameFetchOps, - imageVideoNameFetchOps, - checkPresetsAssets, - checkAssetsCount, - albumFetchOps, -} from '../../../../../../common'; - - -export default function onOffReleasePromiseTest(abilityContext) { - describe('onOffReleasePromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const onTest = async (done, testNum, fetchOp, type, newName, isAudio) => { - try { - let count = 0; - userfilemgr.on(type, () => { count++; }); - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.displayName = newName; - await asset.commitModify(); - await sleep(1000) - expect(count > 0).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - const offTest = async (done, testNum, fetchOp, type, newName, isAudio) => { - try { - let count = 0; - userfilemgr.on(type, () => { count++; }); - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.displayName = newName; - userfilemgr.off(type); - await asset.commitModify(); - await sleep(1000) - expect(count).assertEqual(0); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_ON_01 - * @tc.name : ON - * @tc.desc : ON imageChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ON_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ON_01'; - let currentFetchOps = imageVideoNameFetchOps(testNum, 'Pictures/onAsset/', '01.jpg'); - let type = 'imageChange'; - let newName = 'imageChange.jpg'; - let isAudio = false; - await onTest(done, testNum, currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ON_02 - * @tc.name : ON - * @tc.desc : ON videoChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ON_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ON_02'; - let currentFetchOps = imageVideoNameFetchOps(testNum, 'Videos/onAsset/', '01.mp4'); - let type = 'videoChange'; - let newName = 'videoChange.mp4'; - let isAudio = false; - await onTest(done, testNum, currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ON_03 - * @tc.name : ON - * @tc.desc : ON audioChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ON_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ON_03'; - let currentFetchOps = audioNameFetchOps(testNum, 'Audios/onAsset/', '01.mp3'); - let type = 'audioChange'; - let newName = 'audioChange.mp3'; - let isAudio = true; - await onTest(done, testNum, currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_ON_04 - * @tc.name : ON - * @tc.desc : ON albumChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_ON_04', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_ON_04'; - try { - let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'onAlbum'); - let type: userFileManager.ChangeEvent = 'albumChange'; - let count = 0; - userfilemgr.on(type, () => { count++; }); - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1); - if (!checkAssetCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - const oldName = album.albumName; - fetchAlbumResult.close(); - album.albumName = type.toString(); - await album.commitModify(); - await sleep(1000); - expect(count > 0).assertTrue(); - album.albumName = oldName; - await album.commitModify(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_USERFILE_MGR_OFF_01 - * @tc.name : off - * @tc.desc : off imageChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_OFF_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_OFF_01'; - let currentFetchOps = imageVideoNameFetchOps(testNum, 'Pictures/offAsset/', '01.jpg'); - let type = 'imageChange'; - let newName = 'imageChange.jpg'; - let isAudio = false; - await offTest(done, testNum,currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_OFF_02 - * @tc.name : off - * @tc.desc : off videoChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_OFF_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_OFF_02'; - let currentFetchOps = imageVideoNameFetchOps(testNum, 'Videos/offAsset/', '01.mp4'); - let type = 'videoChange'; - let newName = 'videoChange.mp4'; - let isAudio = false; - await offTest(done, testNum,currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_OFF_03 - * @tc.name : off - * @tc.desc : off audioChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_OFF_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_OFF_03'; - let currentFetchOps = audioNameFetchOps(testNum, 'Audios/offAsset/', '01.mp3'); - let type = 'audioChange'; - let newName = 'audioChange.mp3'; - let isAudio = true; - await offTest(done, testNum,currentFetchOps, type, newName, isAudio) - }); - - /** - * @tc.number : SUB_USERFILE_MGR_OFF_04 - * @tc.name : off - * @tc.desc : off albumChange - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_OFF_04', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_OFF_04'; - try { - let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'offAlbum'); - let type: userFileManager.ChangeEvent = 'albumChange'; - let count = 0; - userfilemgr.on(type, () => { count++; }); - const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1); - if (!checkAssetCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - const oldName = album.albumName - fetchAlbumResult.close(); - album.albumName = type.toString(); - userfilemgr.off(type); - await album.commitModify(); - await sleep(1000); - expect(count).assertEqual(0); - album.albumName = oldName; - await album.commitModify(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_USERFILE_MGR_RELEASE_CALLBACK_01 - * @tc.name : release - * @tc.desc : Release MediaLibrary instance - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_RELEASE_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_RELEASE_CALLBACK_01'; - try { - userfilemgr.release(() => { - expect(true).assertTrue(); - done(); - }); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_USERFILE_MGR_RELEASE_01 - * @tc.name : release - * @tc.desc : Release MediaLibrary instance - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_RELEASE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_RELEASE_PROMISE_01'; - try { - await userfilemgr.release(); - expect(true).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/module.json b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/module.json deleted file mode 100755 index eea188f92a82b7e372b1cecd0627ac6c7c536eff..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/module.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.userfilemgr.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/element/string.json deleted file mode 100755 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/media/icon.png b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/profile/main_pages.json b/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_base/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_base/signature/openharmony_sx.p7b b/multimedia/userfilemgr/userfilemgr_base/signature/openharmony_sx.p7b deleted file mode 100755 index 66b4457a8a81fb8d3356cf46d67226c850944858..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_base/signature/openharmony_sx.p7b and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/app.json b/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/app.json deleted file mode 100755 index 25f1a749f8b57b96979879112a1f5bd21548a92c..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.userfilemgr", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/element/string.json deleted file mode 100755 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/media/app_icon.png b/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/media/app_icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_fileAsset/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/BUILD.gn b/multimedia/userfilemgr/userfilemgr_fileAsset/BUILD.gn deleted file mode 100755 index d2ed44f87ab2b29287d7a70f99dbbd5a369a80c9..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/BUILD.gn +++ /dev/null @@ -1,40 +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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("userfilemgr_fileAsset_js_hap") { - hap_profile = "entry/src/main/module.json" - deps = [ - ":mediaLibrary_js_assets", - ":mediaLibrary_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "ActsUserFileMgrFileAssetJsTest" -} - -ohos_app_scope("medialibrary_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_js_assets("mediaLibrary_js_assets") { - source_dir = "entry/src/main/ets" -} - -ohos_resources("mediaLibrary_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":medialibrary_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/Test.json b/multimedia/userfilemgr/userfilemgr_fileAsset/Test.json deleted file mode 100755 index f2f2978bf89618d51e77bc91d3fc3a5dbdbfdd67..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/Test.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "description": "Configuration for userfilemgr Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.userfilemgr", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", - "mkdir -pv /storage/media/100/local/files/Videos/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", - "mkdir -pv /storage/media/100/local/files/Audios/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", - - "for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - - "for d in Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - - "for d in ModifyCb ModifyPro FileKey R_Cb R_Pro; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", - "for d in ModifyCb ModifyPro FileKey R_Cb R_Pro; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", - "for d in ModifyCb ModifyPro FileKey R_Cb R_Pro; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", - - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsUserFileMgrFileAssetJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100755 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100755 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/index/index.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 624cad290665fcd29dcd579d9582a300479e8ad7..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,68 +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 file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/second/second.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +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 router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/List.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/List.test.ets deleted file mode 100755 index 9a9193148bda1dc7779892ee89d8dc164425a050..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/List.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 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 fileAssetCommitModifyCallbackTest from './fileAssetCommitModifyCallback.test.ets' -import fileAssetCommitModifyPromiseTest from './fileAssetCommitModifyPromise.test.ets' -import fileAssetFavoriteCallbackTest from './fileAssetFavoriteCallback.test.ets' -import fileAssetFavoritePromiseTest from './fileAssetFavoritePromise.test.ets' -import fileAssetFileKeyTest from './fileAssetFileKey.test.ets' -import fileAssetGetThumbnailCallbackTest from './fileAssetGetThumbnailCallback.test.ets' -import fileAssetGetThumbnailPromiseTest from './fileAssetGetThumbnailPromise.test.ets' -import fileAssetOpenCallbackTest from './fileAssetOpenCallback.test.ets' -import fileAssetOpenPromiseTest from './fileAssetOpenPromise.test.ets' -export default function testsuite(abilityContext) { - fileAssetCommitModifyCallbackTest(abilityContext) - fileAssetCommitModifyPromiseTest(abilityContext) - fileAssetFavoriteCallbackTest(abilityContext) - fileAssetFavoritePromiseTest(abilityContext) - fileAssetFileKeyTest(abilityContext) - fileAssetGetThumbnailCallbackTest(abilityContext) - fileAssetGetThumbnailPromiseTest(abilityContext) - fileAssetOpenCallbackTest(abilityContext) - fileAssetOpenPromiseTest(abilityContext) -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyCallback.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyCallback.test.ets deleted file mode 100755 index c6b895bedafc5c2117bbda1ef4f8a62d41bf32a3..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyCallback.test.ets +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - audioNameFetchOps, - imageVideoNameFetchOps, - checkPresetsAssets, - checkAssetsCount, - getPermission, -} from '../../../../../../common'; - -export default function fileAssetCommitModifyCallbackTest(abilityContext) { - describe('fileAssetCommitModifyCallbackTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest') - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) { - try { - let fetchAssetResult; - let fileKey; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - fileKey = userFileManager.AudioKey; - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - fileKey = userFileManager.ImageVideoKey; - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.set(prop, val); - await asset.commitModify(async (err) => { - if (err) { - console.info(`${testNum} err : ${err}`) - expect().assertFail(); - done(); - return; - } - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(fileKey.URI, asset.get(fileKey.URI)); - let ops = { - fetchColumns: [], - predicates: predicates - }; - let newResult; - if (isAudio) { - newResult = await userfilemgr.getAudioAssets(ops); - } else { - newResult = await userfilemgr.getPhotoAssets(ops); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1); - if (!checkAssetCountPass) return; - const newAsset = await newResult.getFirstObject(); - newResult.close(); - expect(newAsset.get(fileKey.TITLE)).assertEqual(val); - done(); - }); - } catch (error) { - console.info(`${testNum} error : ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01 - * @tc.name : commitModify - * @tc.desc : image asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyCb/', '01.jpg'); - let prop = 'title'; - let val = IMAGE_TYPE.toString(); - let isAudio = false; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02 - * @tc.name : commitModify - * @tc.desc : video asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyCb/', '01.mp4'); - let prop = 'title'; - let val = VIDEO_TYPE.toString(); - let isAudio = false; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03 - * @tc.name : commitModify - * @tc.desc : audio asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03'; - let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyCb/', '01.mp3'); - let prop = 'title'; - let val = AUDIO_TYPE.toString(); - let isAudio = true; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyPromise.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyPromise.test.ets deleted file mode 100755 index eccb170496b39fd81d26f104fc28c4b953a1d7a4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetCommitModifyPromise.test.ets +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - checkPresetsAssets, - checkAssetsCount, - audioNameFetchOps, - imageVideoNameFetchOps, -} from '../../../../../../common'; - -export default function fileAssetCommitModifyPromiseTest(abilityContext) { - describe('fileAssetCommitModifyPromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest') - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) { - try { - let fetchAssetResult; - let fileKey; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - fileKey = userFileManager.AudioKey; - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - fileKey = userFileManager.ImageVideoKey; - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.set(prop, val); - await asset.commitModify(); - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(fileKey.URI, asset.get(fileKey.URI)); - let ops = { - fetchColumns: [], - predicates: predicates - }; - let newResult; - if (isAudio) { - newResult = await userfilemgr.getAudioAssets(ops); - } else { - newResult = await userfilemgr.getPhotoAssets(ops); - } - checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1); - if (!checkAssetCountPass) return; - const newAsset = await newResult.getFirstObject(); - newResult.close(); - expect(newAsset.get(fileKey.TITLE)).assertEqual(val); - done(); - } catch (error) { - console.info(`${testNum} error : ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01 - * @tc.name : commitModify - * @tc.desc : image asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyPro/', '01.jpg'); - let prop = 'title'; - let val = IMAGE_TYPE.toString(); - let isAudio = false; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02 - * @tc.name : commitModify - * @tc.desc : video asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyPro/', '01.mp4'); - let prop = 'title'; - let val = VIDEO_TYPE.toString(); - let isAudio = false; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03 - * @tc.name : commitModify - * @tc.desc : audio asset modify title - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03'; - let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyPro/', '01.mp3'); - let prop = 'title'; - let val = AUDIO_TYPE.toString(); - let isAudio = true; - await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoriteCallback.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoriteCallback.test.ets deleted file mode 100644 index 494fe7b4c4f1b90389fa43465f4638cbdb246ecf..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoriteCallback.test.ets +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - checkPresetsAssets, - audioNameFetchOps, - imageVideoNameFetchOps, - checkAssetsCount, - getPermission, -} from '../../../../../../common'; - -export default function fileAssetFavoriteCallbackTest(abilityContext) { - describe('fileAssetFavoriteCallbackTest', function () { - var userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFavorite'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const favoriteDefaultState = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - console.info(`${testNum} asset: ${asset}`); - asset.isFavorite(async (err, isFavorite) => { - if (err) { - expect(false).assertTrue(); - await fetchAssetResult.close(); - done(); - return; - } - expect(isFavorite).assertEqual(false); - fetchAssetResult.close(); - done() - }); - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - const favoriteByTrue = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - asset.favorite(true, async (err) => { - if(err) { - console.info(`${testNum} failed err: ${err}`); - expect(false).assertTrue(); - done(); - return; - } - let isFavorite = await asset.isFavorite(); - expect(isFavorite).assertEqual(true); - fetchAssetResult.close(); - done(); - }); - - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - const favoriteByFalse = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - await asset.favorite(true); - asset.favorite(false, async (err) => { - if(err) { - console.info(`${testNum} failed err: ${err}`); - expect(false).assertTrue(); - done(); - return; - } - let isFavorite = await asset.isFavorite(); - expect(isFavorite).assertEqual(false); - fetchAssetResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '01.jpg'); - let isAudio = false; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002 - * @tc.name : favorite - * @tc.desc : favorite(image) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '02.jpg'); - let isAudio = false; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003 - * @tc.name : favorite - * @tc.desc : favorite(image) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '03.jpg'); - let isAudio = false; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '01.mp4'); - let isAudio = false; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002 - * @tc.name : favorite - * @tc.desc : favorite(video) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '02.mp4'); - let isAudio = false; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003 - * @tc.name : favorite - * @tc.desc : favorite(video) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '03.mp4'); - let isAudio = false; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '01.mp3'); - let isAudio = true; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002 - * @tc.name : favorite - * @tc.desc : favorite(audio) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '02.mp3'); - let isAudio = true; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003 - * @tc.name : favorite - * @tc.desc : favorite(audio) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '03.mp3'); - let isAudio = true; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - }); -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoritePromise.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoritePromise.test.ets deleted file mode 100644 index 2d0fb0233df366e506d22068c735f5d1881c0076..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFavoritePromise.test.ets +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - checkPresetsAssets, - audioNameFetchOps, - imageVideoNameFetchOps, - checkAssetsCount, -} from '../../../../../../common'; - -export default function fileAssetFavoritePromiseTest(abilityContext) { - describe('fileAssetFavoritePromiseTest', function () { - var userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFavorite'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const favoriteDefaultState = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - let isFavorite = await asset.isFavorite(); - expect(isFavorite).assertEqual(false); - fetchAssetResult.close(); - done() - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - const favoriteByTrue = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - await asset.favorite(true); - let isFavorite = await asset.isFavorite(); - expect(isFavorite).assertEqual(true); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - const favoriteByFalse = async function (done, testNum, fetchOp, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - await asset.favorite(true); - await asset.favorite(false); - let isFavorite = await asset.isFavorite(); - expect(isFavorite).assertEqual(false); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum} failed error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '01.jpg'); - let isAudio = false; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002 - * @tc.name : favorite - * @tc.desc : favorite(image) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '02.jpg'); - let isAudio = false; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003 - * @tc.name : favorite - * @tc.desc : favorite(image) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '03.jpg'); - let isAudio = false; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '01.mp4'); - let isAudio = false; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002 - * @tc.name : favorite - * @tc.desc : favorite(video) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '02.mp4'); - let isAudio = false; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003 - * @tc.name : favorite - * @tc.desc : favorite(video) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003'; - let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '03.mp4'); - let isAudio = false; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '01.mp3'); - let isAudio = true; - await favoriteDefaultState(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002 - * @tc.name : favorite - * @tc.desc : favorite(audio) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '02.mp3'); - let isAudio = true; - await favoriteByTrue(done, testNum, currentFetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003 - * @tc.name : favorite - * @tc.desc : favorite(audio) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003'; - let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '03.mp3'); - let isAudio = true; - await favoriteByFalse(done, testNum, currentFetchOp, isAudio); - }); - }); -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets deleted file mode 100644 index a3fdde40be281f25dcfeaa5139315c34a95bf0c1..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - -import { - sleep, - audioFetchOps, - imageVideoFetchOps, - albumFetchOps, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; - -export default function fileAssetFileKeyTest(abilityContext) { - describe('fileAssetFileKeyTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest') - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const AudioKey = userFileManager.AudioKey; - const ImageVideoKey = userFileManager.ImageVideoKey; - const AlbumKey = userFileManager.AlbumKey; - - const getAlbumsByKey = async function (done, testNum, type, fileKey) { - try { - let expectAlbumNum = 1; - let fetchOps = albumFetchOps(testNum, 'Pictures/', 'FileKey'); - let fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumNum); - if (!checkAssetCountPass) return; - const album = await fetchAlbumResult.getFirstObject(); - console.info(`${testNum} fileKey : ${fileKey}`) - console.info(`${testNum} type : ${album[type]}`) - fetchAlbumResult.close(); - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(fileKey, album[type]); - let ops = { - predicates: predicates - }; - - userfilemgr.getPhotoAlbums(ops, async (err, newAlbumResult) => { - if (err) { - console.info(`${testNum}, err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - const fetchCount = newAlbumResult.getCount(); - if (fetchCount <= 0) { - expect(false).assertTrue(); - done(); - return; - } - const currentAlbum = await newAlbumResult.getFirstObject(); - expect(currentAlbum[type]).assertEqual(album[type]); - newAlbumResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum} error : ${error}`) - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAssetsByKey = async function (done, testNum, fileKey) { - try { - let expectAssetNum = 1; - let fetchOps = imageVideoFetchOps(testNum, 'Pictures/FileKey/'); - let fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - console.info(`${testNum} fileKey : ${fileKey}`) - console.info(`${testNum} type : ${asset.get(fileKey)}`) - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(fileKey, asset.get(fileKey)); - let ops = { - fetchColumns: [], - predicates: predicates - }; - - userfilemgr.getPhotoAssets(ops, async (err, newAssetResult) => { - if (err) { - console.info(`${testNum}, err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - const fetchCount = newAssetResult.getCount(); - if (fetchCount <= 0) { - expect(false).assertTrue(); - done(); - return; - } - const currentAsset = await newAssetResult.getFirstObject(); - expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey)); - done(); - }); - } catch (error) { - console.info(`${testNum} error : ${error}`) - expect(false).assertTrue(); - done(); - } - } - - const getAudioAssetsByKey = async function (done, testNum, fileKey) { - try { - let expectAssetNum = 1; - let fetchOps = audioFetchOps(testNum, 'Audios/FileKey/'); - let fetchAssetResult = await userfilemgr.getAudioAssets(fetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - console.info(`${testNum} fileKey : ${fileKey}`) - console.info(`${testNum} type : ${asset.get(fileKey)}`) - let predicates = new dataSharePredicates.DataSharePredicates(); - predicates.equalTo(fileKey, asset.get(fileKey)); - let ops = { - fetchColumns: [], - predicates: predicates - }; - userfilemgr.getAudioAssets(ops, async (err, newAssetResult) => { - if (err) { - console.info(`${testNum}, err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - const fetchCount = newAssetResult.getCount(); - if (fetchCount <= 0) { - expect(false).assertTrue(); - done(); - return; - } - const currentAsset = await newAssetResult.getFirstObject(); - expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey)); - done(); - }); - } catch (error) { - console.info(`${testNum} error : ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01 - * @tc.name : AlbumKey - * @tc.desc : AlbumKey.URI - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01'; - let type = 'albumUri'; - let fileKey = AlbumKey.URI; - await getAlbumsByKey(done, testNum, type, fileKey); - }) - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02 - * @tc.name : AlbumKey - * @tc.desc : AlbumKey.FILE_TYPE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02'; - let type = 'fileType'; - let fileKey = AlbumKey.FILE_TYPE; - await getAlbumsByKey(done, testNum, type, fileKey); - }) - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03 - * @tc.name : AlbumKey - * @tc.desc : AlbumKey.ALBUM_NAME - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03'; - let type = 'albumName'; - let fileKey = AlbumKey.ALBUM_NAME; - await getAlbumsByKey(done, testNum, type, fileKey); - }) - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04 - * @tc.name : AlbumKey - * @tc.desc : AlbumKey.DATE_ADDED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04'; - let type = 'dateAdded'; - let fileKey = AlbumKey.DATE_ADDED; - await getAlbumsByKey(done, testNum, type, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05 - * @tc.name : AlbumKey - * @tc.desc : AlbumKey.DATE_MODIFIED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05'; - let type = 'dateModified'; - let fileKey = AlbumKey.DATE_MODIFIED; - await getAlbumsByKey(done, testNum, type, fileKey); - }); - - //------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.URI - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01'; - let fileKey = ImageVideoKey.URI; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.FILE_TYPE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02'; - let fileKey = ImageVideoKey.FILE_TYPE; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.DISPLAY_NAME - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03'; - let fileKey = ImageVideoKey.DISPLAY_NAME; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.DATE_ADDED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04'; - let fileKey = ImageVideoKey.DATE_ADDED; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.DATE_MODIFIED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05'; - let fileKey = ImageVideoKey.DATE_MODIFIED; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.TITLE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06'; - let fileKey = ImageVideoKey.TITLE; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.DURATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07'; - let fileKey = ImageVideoKey.DURATION; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.WIDTH - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08'; - let fileKey = ImageVideoKey.WIDTH; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.HEIGHT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09'; - let fileKey = ImageVideoKey.HEIGHT; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.DATE_TAKEN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010'; - let fileKey = ImageVideoKey.DATE_TAKEN; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.ORIENTATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011'; - let fileKey = ImageVideoKey.ORIENTATION; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012 - * @tc.name : ImageVideoKey - * @tc.desc : ImageVideoKey.FAVORITE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012'; - let fileKey = ImageVideoKey.FAVORITE; - await getPhotoAssetsByKey(done, testNum, fileKey); - }); - - //---------------------------------------------------------------------------- - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01 - * @tc.name : AudioKey - * @tc.desc : AudioKey.URI - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01'; - let fileKey = AudioKey.URI; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02 - * @tc.name : AudioKey - * @tc.desc : AudioKey.DISPLAY_NAME - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02'; - let fileKey = AudioKey.DISPLAY_NAME; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03 - * @tc.name : AudioKey - * @tc.desc : AudioKey.DATE_ADDED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03'; - let fileKey = AudioKey.DATE_ADDED; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04 - * @tc.name : AudioKey - * @tc.desc : AudioKey.DATE_MODIFIED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04'; - let fileKey = AudioKey.DATE_MODIFIED; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05 - * @tc.name : AudioKey - * @tc.desc : AudioKey.TITLE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05'; - let fileKey = AudioKey.TITLE; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06 - * @tc.name : AudioKey - * @tc.desc : AudioKey.ARTIST - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06'; - let fileKey = AudioKey.ARTIST; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07 - * @tc.name : AudioKey - * @tc.desc : AudioKey.AUDIOALBUM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07'; - let fileKey = AudioKey.AUDIOALBUM; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08 - * @tc.name : AudioKey - * @tc.desc : AudioKey.DURATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08'; - let fileKey = AudioKey.DURATION; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09 - * @tc.name : AudioKey - * @tc.desc : AudioKey.FAVORITE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09'; - let fileKey = AudioKey.FAVORITE; - await getAudioAssetsByKey(done, testNum, fileKey); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailCallback.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailCallback.test.ets deleted file mode 100644 index 12a029cb5b140732a21f368d817480afe8b4b96f..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailCallback.test.ets +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import image from '@ohos.multimedia.image'; - -import { - sleep, - checkPresetsAssets, - checkAssetsCount, - audioNameFetchOps, - imageVideoNameFetchOps, -} from '../../../../../../common'; -export default function fileAssetGetThumbnailCallbackTest(abilityContext) { - describe('fileAssetGetThumbnailCallbackTest', function () { - image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => { }); - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrGetThumbnailTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - async function getThumbnailTest(done, testNum, fetchOp, size, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - if (size == 'default') { - size = { width: 256, height: 256 }; - asset.getThumbnail(async (err, pixelmap) => { - if (err != undefined) { - console.info(`${testNum}:: err1 :${err}`); - expect(false).assertTrue(); - done(); - return; - } - await pixelmap.getImageInfo((err, info) => { - if (err != undefined) { - console.info(`${testNum}:: err2 :${err}`); - expect(false).assertTrue(); - done(); - return; - } - console.info(`${testNum}:: width :${info.size.width} height :${info.size.height}`); - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - }); - }) - } else { - asset.getThumbnail(size, async (err, pixelmap) => { - if (err != undefined) { - console.info(`${testNum}:: err1 :${err}`); - expect(false).assertTrue(); - done(); - return; - } - await pixelmap.getImageInfo((err, info) => { - if (err != undefined) { - console.info(`${testNum}:: err2 :${err}`); - expect(false).assertTrue(); - done(); - return; - } - size.width = (size.width == undefined) ? 256 : Math.floor(size.width); - size.height = (size.height == undefined) ? 256 : Math.floor(size.height); - console.info(`${testNum}:: width :${info.size.width} height :${info.size.height}`); - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - }); - }) - } - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getThumbnailErrorSizeTest(done, testNum, fetchOp, size, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.getThumbnail(size, async (err, pixelmap) => { - if (err != undefined) { - console.info(`${testNum}:: err1 :${err}`); - expect(true).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_001'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '01.jpg'); - let size = 'default'; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_002'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 128, height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_003'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_004'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_005'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 1, height: 1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_006'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_007'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 0, height: 0 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_01_008'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: -128, height: -128 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_001'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '01.mp4'); - let size = 'default'; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_002'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 128, height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_003'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_004'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_005'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 1, height: 1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_006'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_007'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 0, height: 0 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_02_008'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: -128, height: -128 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_001'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '01.mp3'); - let size = 'default'; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_002'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 128, height: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_003'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_004'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { height: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_005'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 1, height: 1 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_006'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_007'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 0, height: 0 }; - let isAudio = true; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_CALLBACK_03_008'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: -128, height: -128 }; - let isAudio = true; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailPromise.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailPromise.test.ets deleted file mode 100644 index 76373fbb9844b27b97dcbc9d55c5ece77394ec28..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetGetThumbnailPromise.test.ets +++ /dev/null @@ -1,499 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import image from '@ohos.multimedia.image'; -import { - sleep, - checkPresetsAssets, - checkAssetsCount, - audioNameFetchOps, - imageVideoNameFetchOps, -} from '../../../../../../common'; - -export default function fileAssetGetThumbnailPromiseTest(abilityContext) { - describe('fileAssetGetThumbnailPromiseTest', function () { - image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => { }); - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrGetThumbnailTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - async function getThumbnailTest(done, testNum, fetchOp, size, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - console.info(`${testNum}:displayName ${asset.displayName}`) - let pixelmap; - if (size == 'default') { - size = { width: 256, height: 256 }; - pixelmap = await asset.getThumbnail() - } else { - pixelmap = await asset.getThumbnail(size) - } - let info = await pixelmap.getImageInfo(); - console.info(`${testNum}:: width :${info.size.width} height :${info.size.height}`); - size.width = (size.width == undefined) ? 256 : Math.floor(size.width); - size.height = (size.height == undefined) ? 256 : Math.floor(size.height); - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function getThumbnailErrorSizeTest(done, testNum, fetchOp, size, isAudio) { - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - try { - let pixelmap; - if (size == 'default') { - size = { width: 256, height: 256 }; - pixelmap = await asset.getThumbnail() - } else { - pixelmap = await asset.getThumbnail(size) - } - expect(false).assertTrue(); - done(); - } catch (err) { - console.info(`${testNum}:: error :${err}`); - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_001'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '01.jpg'); - let size = 'default'; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_002'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 128, height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_003'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_004'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_005'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 1, height: 1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_006'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_007'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: 0, height: 0 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_01_008'; - let dOp = imageVideoNameFetchOps(testNum, 'Pictures/Thumbnail/', '02.jpg'); - let size = { width: -128, height: -128 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_001'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '01.mp4'); - let size = 'default'; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_002'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 128, height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_003'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_004'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { height: 128 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_005'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 1, height: 1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_006'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = false; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_007'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: 0, height: 0 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_02_008'; - let dOp = imageVideoNameFetchOps(testNum, 'Videos/Thumbnail/', '02.mp4'); - let size = { width: -128, height: -128 }; - let isAudio = false; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_001 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_001'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '01.mp3'); - let size = 'default'; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_002 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_002'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 128, height: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_003 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_003'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_004 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_004', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_004'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { height: 128 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_005 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_005', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_005'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 1, height: 1 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_006 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1.1, height: 1.1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_006', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_006'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 1.1, height: 1.1 }; - let isAudio = true; - await getThumbnailTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_007 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_007', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_007'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: 0, height: 0 }; - let isAudio = true; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_008 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_008', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_GETTHUMBNAIL_PROMISE_03_008'; - let dOp = audioNameFetchOps(testNum, 'Audios/Thumbnail/', '02.mp3'); - let size = { width: -128, height: -128 }; - let isAudio = true; - await getThumbnailErrorSizeTest(done, testNum, dOp, size, isAudio); - }); - }); -} - diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenCallback.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenCallback.test.ets deleted file mode 100755 index 2a4c78e367861ca7613734bcddffe2d7ff7c446f..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenCallback.test.ets +++ /dev/null @@ -1,450 +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 userFileManager from '@ohos.filemanagement.userFileManager'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - audioFetchOps, - imageVideoFetchOps, - audioNameFetchOps, - imageVideoNameFetchOps, - isNum, - checkPresetsAssets, - checkAssetsCount, -} from '../../../../../../common'; -export default function fileAssetOpenCallbackTest(abilityContext) { - describe('fileAssetOpenCallbackTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest') - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const rOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset; - let fd; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - asset.open('r', async (err, fd) => { - if (err) { - console.info(`${testNum} :: err: ${err}`); - expect().assertFail(); - done(); - return; - } - expect(isNum(fd)).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - console.log(' bytesRead: ' + res.bytesRead) - expect(res.bytesRead).assertEqual(assetProps.bytesRead); - try { - await fileio.write(fd, buf); - expect().assertFail(); - } catch (error) { - expect(true).assertTrue(); - await asset.close(fd); - } - done(); - }); - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - expect().assertFail(); - await asset.close(fd); - done(); - } - } - - const wOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset, asset1; - let fd, fd1; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - asset1 = await fetchAssetResult.getNextObject(); - fetchAssetResult.close(); - asset.open('w', async (err, fd) => { - if (err) { - console.info(`${testNum} :: err: ${err}`); - expect().assertFail(); - done(); - return; - } - expect(isNum(fd)).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - console.info(`${testNum} :: write: ${write}`); - expect(write).assertEqual(assetProps.write); - let buf1 = new ArrayBuffer(4096); - try { - await fileio.read(fd, buf1); - expect().assertFail(); - } catch (error) { - expect(true).assertTrue(); - } - done(); - }); - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - expect(false).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - } - - const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset, asset1; - let fd, fd1; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - asset.open('rw', async (err, fd) => { - if (err) { - console.info(`${testNum} :: err: ${err}`); - expect().assertFail(); - done(); - return; - } - expect(isNum(fd)).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead).assertEqual(assetProps.bytesRead); - asset1 = await fetchAssetResult.getNextObject(); - fd1 = await asset1.open('r'); - expect(isNum(fd1)).assertTrue(); - let buf1 = new ArrayBuffer(4096); - await fileio.read(fd1, buf1); - let write = await fileio.write(fd, buf1); - expect(write).assertEqual(assetProps.write); - console.info(`res.bytesRead:${res.bytesRead},write:${write}`) - console.info(`fd1:${fd1},fd:${fd}`) - await asset.close(fd); - await asset1.close(fd1); - fetchAssetResult.close(); - done(); - }); - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - await asset.close(fd); - await asset1.close(fd1); - expect().assertFail(); - done(); - } - } - - const closeTest = async function (done, testNum, fetchOp, isAudio) { - let asset; - let fd; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fd = await asset.open('r'); - expect(isNum(fd)).assertTrue(); - asset.close(fd, async (err) => { - if (err) { - console.info(`${testNum} :: err: ${err}`); - expect().assertFail(); - done(); - return; - } - let count = 0 - let buf = new ArrayBuffer(4096); - try { - await fileio.read(fd, buf); - } catch (error) { - count++ - } - try { - await fileio.write(fd, buf); - } catch (error) { - count++ - } - await sleep(1000) - expect(count).assertEqual(2); - done(); - }); - } catch (error) { - console.info(`${testNum} error:${error}`) - await asset.close(fd); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/R_Cb/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = false; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/W_Cb/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/RW_Cb/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Cb/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = false; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Cb/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Cb/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001'; - let fetchOp = audioFetchOps(testNum, 'Audios/R_Cb/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = true; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002'; - let fetchOp = audioFetchOps(testNum, 'Audios/W_Cb/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = true; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003'; - let fetchOp = audioFetchOps(testNum, 'Audios/RW_Cb/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = true; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - //------------------------------------------------------------------------------------ - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01 - * @tc.name : close - * @tc.desc : asset close the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/openClose/', '01.jpg'); - let isAudio = false; - await closeTest(done, testNum, fetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02 - * @tc.name : close - * @tc.desc : asset close the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '01.mp4'); - let isAudio = false; - await closeTest(done, testNum, fetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03 - * @tc.name : close - * @tc.desc : asset close the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03'; - let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '01.mp3'); - let isAudio = true; - await closeTest(done, testNum, fetchOp, isAudio); - }); - }); -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenPromise.test.ets b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenPromise.test.ets deleted file mode 100755 index 0dc81d060737914481b36583afc24d8c8d14356b..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenPromise.test.ets +++ /dev/null @@ -1,426 +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 userFileManager from '@ohos.filemanagement.userFileManager'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - audioFetchOps, - imageVideoFetchOps, - audioNameFetchOps, - imageVideoNameFetchOps, - checkPresetsAssets, - checkAssetsCount, - isNum, -} from '../../../../../../common'; -export default function fileAssetOpenPromiseTest(abilityContext) { - describe('fileAssetOpenPromiseTest', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest') - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const rOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset; - let fd; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - fetchAssetResult.close(); - fd = await asset.open('r'); - expect(isNum(fd)).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - console.log(' bytesRead: ' + res.bytesRead) - expect(res.bytesRead).assertEqual(assetProps.bytesRead); - try { - await fileio.write(fd, buf); - expect().assertFail(); - } catch (error) { - expect(true).assertTrue(); - await asset.close(fd); - done(); - } - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - expect().assertFail(); - await asset.close(fd); - done(); - } - } - - const wOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset, asset1; - let fd, fd1; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - asset1 = await fetchAssetResult.getNextObject(); - fetchAssetResult.close(); - - fd = await asset.open('w'); - expect(isNum(fd)).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - console.info(`${testNum} :: write: ${write}`); - expect(write).assertEqual(assetProps.write); - let buf1 = new ArrayBuffer(4096); - try { - await fileio.read(fd, buf1); - expect().assertFail(); - - } catch (error) { - expect(true).assertTrue(); - - } - done(); - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - expect(false).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - } - - const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount, isAudio) { - let asset, asset1; - let fd, fd1; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount); - if (!checkAssetCountPass) return; - asset = await fetchAssetResult.getFirstObject(); - fd = await asset.open('rw'); - expect(isNum(fd)).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead).assertEqual(assetProps.bytesRead); - asset1 = await fetchAssetResult.getNextObject(); - fd1 = await asset1.open('r'); - expect(isNum(fd1)).assertTrue(); - let buf1 = new ArrayBuffer(4096); - await fileio.read(fd1, buf1); - let write = await fileio.write(fd, buf1); - expect(write).assertEqual(assetProps.write); - console.info(`res.bytesRead:${res.bytesRead},write:${write}`) - console.info(`fd1:${fd1},fd:${fd}`) - await asset.close(fd); - await asset1.close(fd1); - fetchAssetResult.close(); - done(); - } catch (error) { - console.info(`${testNum} :: error: ${error}`); - await asset.close(fd); - await asset1.close(fd1); - expect().assertFail(); - done(); - } - } - - const closeTest = async function (done, testNum, fetchOp, isAudio) { - let asset; - let fd; - try { - let fetchAssetResult; - if (isAudio) { - fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); - } else { - fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); - } - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1); - if (!checkAssetCountPass) return; - const asset = await fetchAssetResult.getFirstObject(); - fd = await asset.open('r'); - expect(isNum(fd)).assertTrue(); - await asset.close(fd); - let count = 0 - let buf = new ArrayBuffer(4096); - try { - await fileio.read(fd, buf); - } catch (error) { - count++ - } - try { - await fileio.write(fd, buf); - } catch (error) { - count++ - } - await sleep(1000) - expect(count).assertEqual(2); - done(); - } catch (error) { - console.info(`${testNum} error:${error}`) - await asset.close(fd); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/R_Pro/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = false; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/W_Pro/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003'; - let fetchOp = imageVideoFetchOps(testNum, 'Pictures/RW_Pro/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Pro/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = false; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Pro/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003'; - let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Pro/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = false; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001 - * @tc.name : open('r') - * @tc.desc : open -r the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001'; - let fetchOp = audioFetchOps(testNum, 'Audios/R_Pro/'); - let assetProps = { - bytesRead: 4096, - }; - let expectCount = 1; - let isAudio = true; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002 - * @tc.name : open('w') - * @tc.desc : open -w the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002'; - let fetchOp = audioFetchOps(testNum, 'Audios/W_Pro/'); - let assetProps = { - write: 4096, - }; - let expectCount = 2; - let isAudio = true; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003'; - let fetchOp = audioFetchOps(testNum, 'Audios/RW_Pro/'); - let assetProps = { - bytesRead: 4096, - write: 4096, - }; - let expectCount = 2; - let isAudio = true; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio); - }); - - //-------------------------------------------------------------------------------- - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01 - * @tc.name : close - * @tc.desc : asset close the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/openClose/', '02.jpg'); - let isAudio = false; - await closeTest(done, testNum, fetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02 - * @tc.name : close - * @tc.desc : asset close the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02'; - let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '02.mp4'); - let isAudio = false; - await closeTest(done, testNum, fetchOp, isAudio); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03 - * @tc.name : close - * @tc.desc : asset close the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03', 2, async function (done) { - let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03'; - let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '02.mp3'); - let isAudio = true; - await closeTest(done, testNum, fetchOp, isAudio); - }); - }); -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/module.json b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/module.json deleted file mode 100755 index eea188f92a82b7e372b1cecd0627ac6c7c536eff..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/module.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.userfilemgr.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/element/string.json deleted file mode 100755 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/media/icon.png b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/profile/main_pages.json b/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_fileAsset/signature/openharmony_sx.p7b b/multimedia/userfilemgr/userfilemgr_fileAsset/signature/openharmony_sx.p7b deleted file mode 100755 index 66b4457a8a81fb8d3356cf46d67226c850944858..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_fileAsset/signature/openharmony_sx.p7b and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/app.json b/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/app.json deleted file mode 100755 index 103cf8e6368fd2a71f15ca4506e1ce4e48a58669..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.userfilemgr", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/element/string.json deleted file mode 100755 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/media/app_icon.png b/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/media/app_icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_noPermission/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/BUILD.gn b/multimedia/userfilemgr/userfilemgr_noPermission/BUILD.gn deleted file mode 100755 index 064eb330ef0284b78f356acb6e0f410ccaa19353..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/BUILD.gn +++ /dev/null @@ -1,40 +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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("userfilemgr_noPermission_js_hap") { - hap_profile = "entry/src/main/module.json" - deps = [ - ":mediaLibrary_js_assets", - ":mediaLibrary_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "ActsUserFileMgrNoPermissionJsTest" -} - -ohos_app_scope("medialibrary_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_js_assets("mediaLibrary_js_assets") { - source_dir = "entry/src/main/ets" -} - -ohos_resources("mediaLibrary_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":medialibrary_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/Test.json b/multimedia/userfilemgr/userfilemgr_noPermission/Test.json deleted file mode 100755 index 5a1ac9d269eeeb77aa520e6aa29f5910e4d90ed5..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/Test.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "description": "Configuration for userfilemgr Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.userfilemgr", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - - ] - }, - { - "type": "ShellKit", - "run-command": [ - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsUserFileMgrNoPermissionJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100755 index 14f230e140160dc5f94ecc462304621178f4cf64..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100755 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/index/index.ets b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index ac301f98781abd45f4d9d98fd7ffecfde9053ed9..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +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 file from '@system.file'; - -import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/second/second.ets b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +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 router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/List.test.ets b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/List.test.ets deleted file mode 100755 index 8742e87b83310b1cb4ee61555e7ea131f20bde6b..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/List.test.ets +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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 userFileMgrNoPermissionCallback from './userFileMgrNoPermissionCallback.test.ets' -import userFileMgrNoPermissionPromise from './userFileMgrNoPermissionPromise.test.ets' -export default function testsuite(abilityContext) { - userFileMgrNoPermissionCallback(abilityContext) - userFileMgrNoPermissionPromise(abilityContext) -} diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionCallback.test.ets b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionCallback.test.ets deleted file mode 100755 index 0a8b665f42720f0f256f0c2928f56369ffbdb690..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionCallback.test.ets +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - allFetchOp, -} from '../../../../../../common'; - - -export default function userFileMgrNoPermissionCallback(abilityContext) { - describe('userFileMgrNoPermissionCallback', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const getPhotoAlbumsTest = async function (done, testNum) { - try { - await userfilemgr.getPhotoAlbums(allFetchOp(), async (err, fetchAlbumResult) => { - if (err != undefined) { - console.info(`${testNum}, err: ${err}`); - expect(true).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - const getPhotoAssetsTest = async function (done, testNum) { - try { - await userfilemgr.getPhotoAssets(allFetchOp(), async (err, fetchAssetResult) => { - if (err != undefined) { - console.info(`${testNum}, err: ${err}`); - expect(true).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - const getAudioAssetsTest = async function (done, testNum) { - try { - await userfilemgr.getAudioAssets(allFetchOp(), async (err, fetchAssetResult) => { - if (err != undefined) { - console.info(`${testNum}, err: ${err}`); - expect(true).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01'; - await getPhotoAlbumsTest(done, testNum); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01 - * @tc.name : getPhotoAssets - * @tc.desc : getPhotoAssets with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01'; - await getPhotoAssetsTest(done, testNum); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01 - * @tc.name : getAudioAssets - * @tc.desc : getAudioAssets with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01'; - await getAudioAssetsTest(done, testNum); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionPromise.test.ets b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionPromise.test.ets deleted file mode 100755 index f48ed9d306979fbcfc592e5a5e039f5c30c9cb06..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/ets/test/userFileMgrNoPermissionPromise.test.ets +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - allFetchOp, -} from '../../../../../../common'; - - -export default function userFileMgrNoPermissionPromise(abilityContext) { - describe('userFileMgrNoPermissionPromise', function () { - const userfilemgr = userFileManager.getUserFileMgr(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const getPhotoAlbumsTest = async function (done, testNum) { - try { - await userfilemgr.getPhotoAlbums(allFetchOp()); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(true).assertTrue(); - done(); - } - } - - const getPhotoAssetsTest = async function (done, testNum) { - try { - await userfilemgr.getPhotoAssets(allFetchOp()); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(true).assertTrue(); - done(); - } - } - - const getAudioAssetsTest = async function (done, testNum) { - try { - await userfilemgr.getAudioAssets(allFetchOp()); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) - expect(true).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01 - * @tc.name : getPhotoAlbums - * @tc.desc : getPhotoAlbums with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01'; - await getPhotoAlbumsTest(done, testNum); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01 - * @tc.name : getPhotoAssets - * @tc.desc : getPhotoAssets with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01'; - await getPhotoAssetsTest(done, testNum); - }); - - /** - * @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01 - * @tc.name : getAudioAssets - * @tc.desc : getAudioAssets with no permission - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) { - const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01'; - await getAudioAssetsTest(done, testNum); - }); - }); -} - - diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/module.json b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/module.json deleted file mode 100755 index 0bb8c230ed6bce84005fc4df0d8651857e2452c9..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/module.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.userfilemgr.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.READ_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_IMAGEVIDEO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_AUDIO", - "reason":"use ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_DOCUMENT", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/element/string.json b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/element/string.json deleted file mode 100755 index 32237ee203edf64926964fb238fa44e396ddf577..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/media/icon.png b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/profile/main_pages.json b/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index 96b478210df9884592229ae2db6f6bb7f86c14f4..0000000000000000000000000000000000000000 --- a/multimedia/userfilemgr/userfilemgr_noPermission/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] -} \ No newline at end of file diff --git a/multimedia/userfilemgr/userfilemgr_noPermission/signature/openharmony_sx.p7b b/multimedia/userfilemgr/userfilemgr_noPermission/signature/openharmony_sx.p7b deleted file mode 100755 index 66b4457a8a81fb8d3356cf46d67226c850944858..0000000000000000000000000000000000000000 Binary files a/multimedia/userfilemgr/userfilemgr_noPermission/signature/openharmony_sx.p7b and /dev/null differ