未验证 提交 ca54a03f 编写于 作者: O openharmony_ci 提交者: Gitee

!6735 monthly分支用例下库

Merge pull request !6735 from 秦莉文/monthly_20221018
......@@ -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 = [
......
# 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"
}
{
"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
{
"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
/*
* 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.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;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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
/**
* 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')
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
/*
* 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
{
"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
}
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
# 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"
}
{
"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
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;
}
}
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
/*
* 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
/*
* 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
/*
* 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)
}
/*
* 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);
});
});
}
/*
* 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);
});
});
}
/*
* 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
/*
* 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
{
"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"
}
]
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"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
}
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
# 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"
}
{
"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
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;
}
}
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
/*
* 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
/*
* 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
/*
* 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)
}
/*
* 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);
});
});
}
/*
* 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);
});
});
}
/*
* 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);
});
});
}
/*
* 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);
});
});
}
/*
* 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);
});
});
}
/*
* 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();
}
});
});
}
{
"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"
}
]
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"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
}
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
# 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"
}
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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册