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

!4943 XTS Split 0812

Merge pull request !4943 from caochuan/master
...@@ -37,7 +37,12 @@ group("multimedia") { ...@@ -37,7 +37,12 @@ group("multimedia") {
"media/media_js_standard/videoPlayer:video_player_js_hap", "media/media_js_standard/videoPlayer:video_player_js_hap",
"medialibrary/mediaLibrary_album:mediaLibrary_album_hap", "medialibrary/mediaLibrary_album:mediaLibrary_album_hap",
"medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap", "medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap",
"medialibrary/mediaLibrary_file:mediaLibrary_file_hap",
"medialibrary/mediaLibrary_fileAsset:mediaLibrary_fileAsset_hap",
"medialibrary/mediaLibrary_fileAssetUri:mediaLibrary_fileAssetUri_hap",
"medialibrary/mediaLibrary_fileKey:mediaLibrary_fileKey_hap",
"medialibrary/mediaLibrary_fileResult:mediaLibrary_fileResult_hap", "medialibrary/mediaLibrary_fileResult:mediaLibrary_fileResult_hap",
"medialibrary/mediaLibrary_getThumbnail:mediaLibrary_getThumbnail_hap",
"medialibrary/mediaLibrary_js_standard:mediaLibrary_js_hap", "medialibrary/mediaLibrary_js_standard:mediaLibrary_js_hap",
] ]
} else { } else {
......
...@@ -23,6 +23,10 @@ const presetsCount = { ...@@ -23,6 +23,10 @@ const presetsCount = {
ActsMediaLibraryAlbumFileResultPro: { assetsCount: 123, albumsCount: 6 }, ActsMediaLibraryAlbumFileResultPro: { assetsCount: 123, albumsCount: 6 },
//ActsMediaLibraryAlbumFileResultCb test case create 1 album 5 assets //ActsMediaLibraryAlbumFileResultCb test case create 1 album 5 assets
ActsMediaLibraryAlbumFileResultCb: { assetsCount: 118, albumsCount: 5 }, ActsMediaLibraryAlbumFileResultCb: { assetsCount: 118, albumsCount: 5 },
ActsMediaLibraryFileKey: { assetsCount: 4, albumsCount: 4 },
ActsMediaLibraryFileAsset: { assetsCount: 4, albumsCount: 4 },
ActsMediaLibraryFile: { assetsCount: 4, albumsCount: 4 },
ActsMediaLibraryGetThumbnail: { assetsCount: 3, albumsCount: 3 },
} }
const IMAGE_TYPE = mediaLibrary.MediaType.IMAGE; const IMAGE_TYPE = mediaLibrary.MediaType.IMAGE;
...@@ -128,6 +132,8 @@ const checkPresetsAssets = async function (media, hapName) { ...@@ -128,6 +132,8 @@ const checkPresetsAssets = async function (media, hapName) {
const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) { const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) {
if (!fetchFileResult) { if (!fetchFileResult) {
console.info(`${testNum}:: fetchFileResult error:`); console.info(`${testNum}:: fetchFileResult error:`);
expect(false).assertTrue();
done();
return false return false
} }
let count = await fetchFileResult.getCount(); let count = await fetchFileResult.getCount();
...@@ -143,6 +149,8 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC ...@@ -143,6 +149,8 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC
const checkAlbumsCount = function (done, testNum, albumList, expectCount) { const checkAlbumsCount = function (done, testNum, albumList, expectCount) {
if (!Array.isArray(albumList)) { if (!Array.isArray(albumList)) {
console.info(`${testNum}:: albumList error:`); console.info(`${testNum}:: albumList error:`);
expect(false).assertTrue();
done();
return false return false
} }
let albumsCount = albumList.length; let albumsCount = albumList.length;
...@@ -174,17 +182,18 @@ const getPermission = async function (name = 'ohos.acts.multimedia.mediaLibrary' ...@@ -174,17 +182,18 @@ const getPermission = async function (name = 'ohos.acts.multimedia.mediaLibrary'
} }
const MODIFY_ERROR_CODE_01 = '-1000'; const MODIFY_ERROR_CODE_01 = '-1000';
const isNum = function (value) {
return typeof value === 'number' && !isNaN(value);
}
export { export {
getPermission, getPermission,
IMAGE_TYPE, IMAGE_TYPE,
VIDEO_TYPE, VIDEO_TYPE,
AUDIO_TYPE, AUDIO_TYPE,
FILE_TYPE, FILE_TYPE,
FILEKEY, FILEKEY,
sleep, sleep,
allFetchOp, allFetchOp,
fetchOps, fetchOps,
nameFetchOps, nameFetchOps,
...@@ -192,9 +201,9 @@ export { ...@@ -192,9 +201,9 @@ export {
albumFetchOps, albumFetchOps,
albumTwoTypesFetchOps, albumTwoTypesFetchOps,
albumThreeTypesFetchOps, albumThreeTypesFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAssetsCount, checkAssetsCount,
checkAlbumsCount, checkAlbumsCount,
MODIFY_ERROR_CODE_01, MODIFY_ERROR_CODE_01,
isNum,
} }
文件模式从 100644 更改为 100755
...@@ -46,9 +46,7 @@ ...@@ -46,9 +46,7 @@
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -p off", "hilog -p off",
"hilog -b D -D 0xD002B70", "hilog -b D -D 0xD002B70",
"aa start -a com.ohos.photos.MainAbility -b com.ohos.photos", "scanner_demo",
"sleep 10",
"cem publish -e usual.event.SCREEN_OFF",
"sleep 10" "sleep 10"
], ],
"teardown-command":[ "teardown-command":[
......
...@@ -16,14 +16,12 @@ import file from '@system.file'; ...@@ -16,14 +16,12 @@ import file from '@system.file';
import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index"
import testsuite from "../../test/List.test.ets" import testsuite from "../../test/List.test.ets"
import { getPermission } from "../../../../../../../common"
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear(){ aboutToAppear(){
getPermission()
console.info("start run testcase!!!!") console.info("start run testcase!!!!")
const core = Core.getInstance() const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
......
...@@ -27,12 +27,14 @@ import { ...@@ -27,12 +27,14 @@ import {
albumThreeTypesFetchOps, albumThreeTypesFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAlbumsCount,
getPermission,
} from '../../../../../../common'; } from '../../../../../../common';
export default function albumGetFileAssetsCallbackTest(abilityContext) { export default function albumGetFileAssetsCallbackTest(abilityContext) {
describe('albumGetFileAssetsCallbackTest', function () { describe('albumGetFileAssetsCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext); const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () { beforeAll(async function () {
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryAlbum'); await checkPresetsAssets(media, 'ActsMediaLibraryAlbum');
}); });
beforeEach(function () { }); beforeEach(function () { });
......
...@@ -47,9 +47,7 @@ ...@@ -47,9 +47,7 @@
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -p off", "hilog -p off",
"hilog -b D -D 0xD002B70", "hilog -b D -D 0xD002B70",
"aa start -a com.ohos.photos.MainAbility -b com.ohos.photos", "scanner_demo",
"sleep 10",
"cem publish -e usual.event.SCREEN_OFF",
"sleep 10" "sleep 10"
] ]
}, },
......
...@@ -16,14 +16,12 @@ import file from '@system.file'; ...@@ -16,14 +16,12 @@ import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets" import testsuite from "../../test/List.test.ets"
import { getPermission } from "../../../../../../../common"
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear(){ aboutToAppear(){
getPermission()
console.info("start run testcase!!!!") console.info("start run testcase!!!!")
const core = Core.getInstance() const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
......
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
import favoriteTestPromise from './favoriteTestPromise.test.ets' import favoriteTestPromise from './favoriteTestPromise.test.ets'
import favoriteTestCallback from './favoriteTestCallback.test.ets' import favoriteTestCallback from './favoriteTestCallback.test.ets'
export default function testsuite(abilityContext) { export default function testsuite(abilityContext) {
favoriteTestPromise(abilityContext)
favoriteTestCallback(abilityContext) favoriteTestCallback(abilityContext)
favoriteTestPromise(abilityContext)
} }
...@@ -24,12 +24,14 @@ import { ...@@ -24,12 +24,14 @@ import {
checkPresetsAssets, checkPresetsAssets,
nameFetchOps, nameFetchOps,
checkAssetsCount, checkAssetsCount,
getPermission,
} from '../../../../../../common'; } from '../../../../../../common';
export default function favoriteTestCallbackTest(abilityContext) { export default function favoriteTestCallbackTest(abilityContext) {
describe('favoriteTestCallbackTest', function () { describe('favoriteTestCallbackTest', function () {
var media = mediaLibrary.getMediaLibrary(abilityContext); var media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () { beforeAll(async function () {
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFavorite'); await checkPresetsAssets(media, 'ActsMediaLibraryFavorite');
}); });
beforeEach(function () { }); beforeEach(function () { });
......
{
"app":{
"bundleName":"ohos.acts.multimedia.mediaLibrary",
"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("mediaLibrary_file_hap") {
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryFile"
}
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 mediaLibrary Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary",
"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,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,Dynamic}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,Dynamic}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,Dynamic}",
"mkdir -pv /storage/media/100/local/files/Documents/{Static,Dynamic}",
"for d in Static; do for i in $$(seq 6); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 6); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 6); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in Static; do for i in $$(seq 6); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/Dynamic/01.jpg",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/Dynamic/01.mp4",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/Dynamic/01.mp3",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/Dynamic/01.dat",
"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 D -D 0xD002B70",
"scanner_demo",
"sleep 10"
]
},
{
"test-file-name": [
"ActsMediaLibraryFile.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 fileTestPromise from './fileTestPromise.test.ets'
export default function testsuite(abilityContext) {
fileTestPromise(abilityContext)
}
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:mainability_description",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "ohos.acts.multimedia.mediaLibrary.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_MEDIA",
"reason":"use ohos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.WRITE_MEDIA",
"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.mediaLibrary",
"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("mediaLibrary_fileAsset_hap") {
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryFileAsset"
}
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 mediaLibrary Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary",
"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,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,RW,R,W,openClose}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,RW,R,W,openClose}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,RW,R,W,openClose}",
"mkdir -pv /storage/media/100/local/files/Documents/{Static,RW,R,W,openClose}",
"for d in RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; 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 D -D 0xD002B70",
"scanner_demo",
"sleep 10"
]
},
{
"test-file-name": [
"ActsMediaLibraryFileAsset.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 fileAssetPromise2 from './fileAssetPromise2.test.ets'
import fileAssetTestPromise from './fileAssetTestPromise.test.ets'
export default function testsuite(abilityContext) {
fileAssetPromise2(abilityContext)
fileAssetTestPromise(abilityContext)
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -14,97 +14,78 @@ ...@@ -14,97 +14,78 @@
*/ */
import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import { import {
sleep, sleep,
IMAGE_TYPE,
AUDIO_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
getPermission,
fetchOps,
nameFetchOps,
} from '../../../../../../common'; } from '../../../../../../common';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
function printAttr(asset) {
for (const key in asset) {
console.info(`${key}: asset[key]`);
}
}
function checkAttrs(done, asset, tNum) {
let passed = true;
for (const key in asset) {
if (asset[key] == undefined) {
passed = false;
break;
}
}
if (passed) {
console.info(`FileAsset checkAttrs ${tNum} passed`);
expect(true).assertTrue();
done();
} else {
console.info(`FileAsset checkAttrs ${tNum} failed`);
expect(false).assertTrue();
done();
}
}
export default function fileAssetPromise2Test(abilityContext){ export default function fileAssetPromise2Test(abilityContext) {
describe('fileAssetPromise2Test', function () { describe('fileAssetPromise2Test', function () {
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
let imagesfetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/Dynamic/', imageType.toString()],
};
let videosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
};
let audiosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
};
let allTypefetchOp = {
selections: '',
selectionArgs: [],
};
const context = featureAbility.getContext();
const media = mediaLibrary.getMediaLibrary(abilityContext); const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(function () { }); beforeAll(async function () {
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileKey')
});
beforeEach(function () { }); beforeEach(function () { });
afterEach(async function () { await sleep(200)}); afterEach(async function () {
await sleep()
});
afterAll(function () { }); afterAll(function () { });
/** const checkCommitModify = async function (done, testNum, fetchOp, prop, val) {
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_001
* @tc.name : commitModify
* @tc.desc : Modify displayName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_001', 0, async function (done) {
try { try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp); console.info(`${testNum} fetchOp : ${JSON.stringify(fetchOp)}`)
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
const newName = 'newName' + new Date().getTime() + '.jpg'; const oldVal = asset[prop]
asset.displayName = newName; asset[prop] = val;
const id = asset.id; const id = asset.id;
await asset.commitModify(); await asset.commitModify();
let currentfetchOp = { let currentfetchOp = {
selections: fileKeyObj.ID + '= ?', selections: FILEKEY.ID + '= ?',
selectionArgs: [id + ''], selectionArgs: [id + ''],
}; };
const fetchFileResult2 = await media.getFileAssets(currentfetchOp); const fetchFileResult2 = await media.getFileAssets(currentfetchOp);
const currentAsset = await fetchFileResult2.getFirstObject(); const currentAsset = await fetchFileResult2.getFirstObject();
expect(currentAsset.displayName == newName).assertTrue(); expect(currentAsset[prop]).assertEqual(val);
asset[prop] = oldVal;
await asset.commitModify();
await fetchFileResult.close();
done(); done();
} catch (error) { } catch (error) {
console.info('FileAsset commitModify 001 failed, message = ' + error); console.info(`${testNum} error : ${error}`)
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_001
* @tc.name : commitModify
* @tc.desc : Modify displayName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_001'
let fetchOp = nameFetchOps('Pictures/Static/', '01', IMAGE_TYPE);
let prop = 'displayName'
let val = new Date().getTime() + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
}); });
/** /**
...@@ -116,27 +97,11 @@ export default function fileAssetPromise2Test(abilityContext){ ...@@ -116,27 +97,11 @@ export default function fileAssetPromise2Test(abilityContext){
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_FILEASSET_commitModify_promise_002', 0, async function (done) { it('SUB_MEDIA_FILEASSET_commitModify_promise_002', 0, async function (done) {
try { let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_002'
const fetchFileResult = await media.getFileAssets(imagesfetchOp); let fetchOp = nameFetchOps('Pictures/Static/', '02', IMAGE_TYPE);
const asset = await fetchFileResult.getFirstObject(); let prop = 'title'
const newTitle = 'newTitle' + new Date().getTime(); let val = new Date().getTime() + 'newTitle'
asset.title = newTitle; await checkCommitModify(done, testNum, fetchOp, prop, val)
const id = asset.id;
await asset.commitModify();
let currentfetchOp = {
selections: fileKeyObj.ID + '= ?',
selectionArgs: [id + ''],
};
const fetchFileResult2 = await media.getFileAssets(currentfetchOp);
const currentAsset = await fetchFileResult2.getFirstObject();
expect(currentAsset.title == newTitle).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 002 failed, message = ' + error);
expect(false).assertTrue();
done();
}
}); });
/** /**
...@@ -148,29 +113,11 @@ export default function fileAssetPromise2Test(abilityContext){ ...@@ -148,29 +113,11 @@ export default function fileAssetPromise2Test(abilityContext){
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_FILEASSET_commitModify_promise_003', 0, async function (done) { it('SUB_MEDIA_FILEASSET_commitModify_promise_003', 0, async function (done) {
try { let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_003'
let fetchOp = nameFetchOps('Pictures/Static/', '03', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(imagesfetchOp); let prop = 'relativePath'
const asset = await fetchFileResult.getFirstObject(); let val = 'Pictures/Temp/'
let newrelativePath = 'Pictures/Temp/'; await checkCommitModify(done, testNum, fetchOp, prop, val)
asset.relativePath = newrelativePath;
const id = asset.id;
await asset.commitModify();
let currentfetchOp = {
selections: fileKeyObj.ID + '= ?',
selectionArgs: [id + ''],
};
const fetchFileResult2 = await media.getFileAssets(currentfetchOp);
const currentAsset = await fetchFileResult2.getFirstObject();
expect(currentAsset.relativePath == newrelativePath).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
}); });
/** /**
...@@ -182,30 +129,12 @@ export default function fileAssetPromise2Test(abilityContext){ ...@@ -182,30 +129,12 @@ export default function fileAssetPromise2Test(abilityContext){
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_FILEASSET_commitModify_promise_004', 0, async function (done) { it('SUB_MEDIA_FILEASSET_commitModify_promise_004', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
let neworientation = 1;
if (asset.orientation == 1) {
neworientation = 0;
}
asset.orientation = neworientation;
const id = asset.id;
await asset.commitModify();
let currentfetchOp = { let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_004'
selections: fileKeyObj.ID + '= ?', let fetchOp = nameFetchOps('Pictures/Static/', '04', IMAGE_TYPE);
selectionArgs: [id + ''], let prop = 'orientation'
}; let val = 1
const fetchFileResult2 = await media.getFileAssets(currentfetchOp); await checkCommitModify(done, testNum, fetchOp, prop, val)
const currentAsset = await fetchFileResult2.getFirstObject();
expect(currentAsset.orientation == neworientation).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 004 failed, message = ' + error);
expect(false).assertTrue();
done();
}
}); });
/** /**
...@@ -218,7 +147,8 @@ export default function fileAssetPromise2Test(abilityContext){ ...@@ -218,7 +147,8 @@ export default function fileAssetPromise2Test(abilityContext){
*/ */
it('SUB_MEDIA_FILEASSET_isDirectory_promise_001', 0, async function (done) { it('SUB_MEDIA_FILEASSET_isDirectory_promise_001', 0, async function (done) {
try { try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp); let fetchOp = nameFetchOps('Pictures/Static/', '05', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(fetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory(); const isDir = await asset.isDirectory();
expect(!isDir).assertTrue(); expect(!isDir).assertTrue();
...@@ -229,95 +159,6 @@ export default function fileAssetPromise2Test(abilityContext){ ...@@ -229,95 +159,6 @@ export default function fileAssetPromise2Test(abilityContext){
done(); done();
} }
}); });
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_001
* @tc.name : attrs
* @tc.desc : imagesfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_001', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '001');
} catch (error) {
console.info('FileAsset checkAttr 001 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_002
* @tc.name : attrs
* @tc.desc : videosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_002', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '002');
} catch (error) {
console.info('FileAsset checkAttr 002 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_003
* @tc.name : attrs
* @tc.desc : audiosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_003', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(audiosfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '003');
} catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_004
* @tc.name : attrs
* @tc.desc : album attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_004', 0, async function (done) {
try {
const albumList = await media.getAlbums(allTypefetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '004');
} catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
}); });
} }
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:mainability_description",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "ohos.acts.multimedia.mediaLibrary.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_MEDIA",
"reason":"use ohos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.WRITE_MEDIA",
"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.mediaLibrary",
"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("mediaLibrary_fileAssetUri_hap") {
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryFileAssetUri"
}
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 mediaLibrary Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary",
"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,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/Static",
"mkdir -pv /storage/media/100/local/files/Videos/Static",
"mkdir -pv /storage/media/100/local/files/Audios/Static",
"mkdir -pv /storage/media/100/local/files/Documents/Static",
"for d in Static; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in Static; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; 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 D -D 0xD002B70",
"scanner_demo",
"sleep 10"
]
},
{
"test-file-name": [
"ActsMediaLibraryFileAssetUri.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 fileAssetUriTestPromise from './fileAssetUriTestPromise.test.ets'
import fileAssetUriTestCallback from './fileAssetUriTestCallback.test.ets'
export default function testsuite(abilityContext) {
fileAssetUriTestCallback(abilityContext)
fileAssetUriTestPromise(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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
IMAGE_TYPE,
AUDIO_TYPE,
VIDEO_TYPE,
FILE_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
fetchOps,
getPermission,
} from '../../../../../../common';
export default function filekeyTestCallbackTest(abilityContext) {
describe('filekeyTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileAssetUri');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const serachUri = async (done, testNum, fetchOp, type) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
if (!checkAssetCountPass) return;
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
const serachUri = `datashare:///media/${type}/${id}`;
console.info(`${testNum} :uri ${uri};serachUri${serachUri})`)
let serchfetchOp = {
uri: serachUri.toString(),
selections: '',
selectionArgs: [],
};
media.getFileAssets(serchfetchOp, async (err, result) => {
if (err) {
console.info(`${testNum}, err: ${err}`)
expect(false).assertTrue();
done();
return;
}
checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1);
if (!checkAssetCountPass) return;
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
done();
});
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001
* @tc.name : uri
* @tc.desc : serach image asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001';
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE);
let type = 'image';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002
* @tc.name : uri
* @tc.desc : serach audio asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002';
let currentFetchOp = fetchOps('Audios/Static/', AUDIO_TYPE);
let type = 'audio';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003
* @tc.name : uri
* @tc.desc : serach video asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003';
let currentFetchOp = fetchOps('Videos/Static/', VIDEO_TYPE);
let type = 'video';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004
* @tc.name : uri
* @tc.desc : serach file asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004';
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE);
let type = 'file';
await serachUri(done, testNum, currentFetchOp, type);
});
});
}
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
IMAGE_TYPE,
AUDIO_TYPE,
VIDEO_TYPE,
FILE_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
fetchOps,
getPermission,
} from '../../../../../../common';
export default function filekeyTestPromiseTest(abilityContext) {
describe('filekeyTestPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileAssetUri');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const serachUri = async (done, testNum, fetchOp, type) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
if (!checkAssetCountPass) return;
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
const serachUri = `datashare:///media/${type}/${id}`;
console.info(`${testNum} :uri ${uri};serachUri${serachUri})`)
let serchfetchOp = {
uri: serachUri.toString(),
selections: '',
selectionArgs: [],
};
const result = await media.getFileAssets(serchfetchOp);
checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1);
if (!checkAssetCountPass) return;
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001
* @tc.name : uri
* @tc.desc : serach image asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001';
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE);
let type = 'image';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002
* @tc.name : uri
* @tc.desc : serach audio asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002';
let currentFetchOp = fetchOps('Audios/Static/', AUDIO_TYPE);
let type = 'audio';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003
* @tc.name : uri
* @tc.desc : serach video asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003';
let currentFetchOp = fetchOps('Videos/Static/', VIDEO_TYPE);
let type = 'video';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004
* @tc.name : uri
* @tc.desc : serach file asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004';
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE);
let type = 'file';
await serachUri(done, testNum, currentFetchOp, type);
});
});
}
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:mainability_description",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "ohos.acts.multimedia.mediaLibrary.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_MEDIA",
"reason":"use ohos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.WRITE_MEDIA",
"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.mediaLibrary",
"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("mediaLibrary_fileKey_hap") {
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryFileKey"
}
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 mediaLibrary Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary",
"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,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/ImageInfo",
"mkdir -pv /storage/media/100/local/files/Audios/Static",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/ImageInfo/01.jpg",
"cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/Static/01.mp3",
"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 D -D 0xD002B70",
"scanner_demo",
"sleep 10"
]
},
{
"test-file-name": [
"ActsMediaLibraryFileKey.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 filekeyTestCallback from './filekeyTestCallback.test.ets'
import filekeyTestPromise from './filekeyTestPromise.test.ets'
export default function testsuite(abilityContext) {
filekeyTestCallback(abilityContext)
filekeyTestPromise(abilityContext)
}
...@@ -14,40 +14,18 @@ ...@@ -14,40 +14,18 @@
*/ */
import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import { import {
sleep, sleep,
IMAGE_TYPE,
AUDIO_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
fetchOps,
getPermission,
} from '../../../../../../common'; } from '../../../../../../common';
let fileKeyObj = mediaLibrary.FileKey;
let fileType = mediaLibrary.MediaType.FILE;
let imageType = mediaLibrary.MediaType.IMAGE;
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
let imagesfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
let videosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
};
let audiosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
};
let allsfetchOp = {
selections: '',
selectionArgs: [],
};
//const context = featureAbility.getContext();
//const media = mediaLibrary.getMediaLibrary(context);
const filekeys = { const filekeys = {
parent: 'PARENT', parent: 'PARENT',
...@@ -60,93 +38,65 @@ const filekeys = { ...@@ -60,93 +38,65 @@ const filekeys = {
height: 'HEIGHT', height: 'HEIGHT',
orientation: 'ORIENTATION', orientation: 'ORIENTATION',
albumId: 'ALBUM_ID', albumId: 'ALBUM_ID',
albumName: 'ALBUM_NAME',
artist: 'ARTIST', artist: 'ARTIST',
audioAlbum: 'AUDIOALBUM', audioAlbum: 'AUDIOALBUM',
dateModified: 'DATE_MODIFIED', dateModified: 'DATE_MODIFIED',
dateTaken: 'DATE_TAKEN', dateTaken: 'DATE_TAKEN',
relativePath: 'RELATIVE_PATH',
displayName: 'DISPLAY_NAME',
} }
//async function getFileAssetsBy(done, type) { export default function filekeyTestCallbackTest(abilityContext) {
// let assetOp = imagesfetchOp describe('filekeyTestCallbackTest', function () {
// if(type == 'audioAlbum' || type == 'artist' || type == 'duration') {
// assetOp = audiosfetchOp
// }
// const fetchFileResult = await media.getFileAssets(assetOp);
// const asset = await fetchFileResult.getFirstObject();
// let Op = {
// selections: fileKeyObj[filekeys[type]] + '= ?',
// selectionArgs: [asset[type] + ''],
// };
//
// try {
// media.getFileAssets(Op, async(err, fetchFileResult) => {
// if (fetchFileResult == undefined) {
// expect(false).assertTrue();
// done();
// } else {
// try {
// const fetchCount = await fetchFileResult.getCount();
// console.log('getFileAssetsBy ' + type + 'fetchCount = ' + fetchCount);
// expect(fetchCount > 0).assertTrue();
// done();
// } catch (error) {
// console.log('getFileAssetsBy ' + type + ' failed error message = ' + error);
// }
// }
// });
// } catch (error) {
// expect(false).assertTrue();
// done();
// }
//}
function printAttr (done, asset, tNum) {
}
export default function filekeyTestCallBackTest(abilityContext){
describe('filekeyTestCallBackTest', function () {
beforeAll(function () {});
beforeEach(function () {});
afterEach(async function () { await sleep(200)});
afterAll(function () {});
const media = mediaLibrary.getMediaLibrary(abilityContext); const media = mediaLibrary.getMediaLibrary(abilityContext);
async function getFileAssetsBy(done, type) { beforeAll(async function () {
let assetOp = imagesfetchOp await getPermission();
if(type == 'audioAlbum' || type == 'artist' || type == 'duration') { await checkPresetsAssets(media, 'ActsMediaLibraryFileKey')
assetOp = audiosfetchOp });
beforeEach(function () { });
afterEach(async function () {
await sleep()
});
afterAll(function () { });
async function getFileAssetsBy(done, testNum, type, count = 1) {
try {
let assetOp = fetchOps('Pictures/ImageInfo/', IMAGE_TYPE);
if (type == 'audioAlbum' || type == 'artist' || type == 'duration') {
assetOp = fetchOps('Audios/Static/', AUDIO_TYPE);
} }
const fetchFileResult = await media.getFileAssets(assetOp); console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`)
let fetchFileResult = await media.getFileAssets(assetOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
let Op = { let Op = {
selections: fileKeyObj[filekeys[type]] + '= ?', selections: FILEKEY[filekeys[type]] + '= ?',
selectionArgs: [asset[type] + ''], selectionArgs: [asset[type] + ''],
}; };
media.getFileAssets(Op, async (err, fetchFileResult) => {
try { if(err) {
media.getFileAssets(Op, async(err, fetchFileResult) => { console.info(`${testNum}, err: ${err}`)
if (fetchFileResult == undefined) {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { return;
try {
const fetchCount = await fetchFileResult.getCount();
console.log('getFileAssetsBy ' + type + 'fetchCount = ' + fetchCount);
expect(fetchCount > 0).assertTrue();
done();
} catch (error) {
console.log('getFileAssetsBy ' + type + ' failed error message = ' + error);
}
} }
const fetchCount = fetchFileResult.getCount();
const currentAsset = await fetchFileResult.getFirstObject();
expect(currentAsset[type]).assertEqual(asset[type]);
expect(fetchCount>0).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
} }
/** /**
* @tc.number : test_fileKey_001 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey parentOp * @tc.desc : filekey parentOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -154,245 +104,207 @@ export default function filekeyTestCallBackTest(abilityContext){ ...@@ -154,245 +104,207 @@ export default function filekeyTestCallBackTest(abilityContext){
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_001', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001', 0, async function (done) {
getFileAssetsBy(done, 'parent'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001'
await getFileAssetsBy(done, testNum, 'parent');
}); });
/** /**
* @tc.number : test_fileKey_002 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey mimeTypeOp * @tc.desc : filekey mimeTypeOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_002', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002', 0, async function (done) {
getFileAssetsBy(done, 'mimeType'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002'
await getFileAssetsBy(done, testNum, 'mimeType');
}); });
/** /**
* @tc.number : test_fileKey_003 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey sizeOp * @tc.desc : filekey sizeOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_003', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003', 0, async function (done) {
getFileAssetsBy(done, 'size'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003'
await getFileAssetsBy(done, testNum, 'size');
}); });
/** /**
* @tc.number : test_fileKey_004 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey dateAddedOp * @tc.desc : filekey dateAddedOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_004', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004'
getFileAssetsBy(done, 'dateAdded'); await getFileAssetsBy(done, testNum, 'dateAdded', 2);
}); });
/** /**
* @tc.number : test_fileKey_005 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey dateModifiedOp * @tc.desc : filekey dateModifiedOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_005', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005', 0, async function (done) {
getFileAssetsBy(done, 'dateModified'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005'
await getFileAssetsBy(done, testNum, 'dateModified', 2);
}); });
/** /**
* @tc.number : test_fileKey_006 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey dateTakenOp * @tc.desc : filekey dateTakenOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_006', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006', 0, async function (done) {
getFileAssetsBy(done, 'dateTaken'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006'
await getFileAssetsBy(done, testNum, 'dateTaken', 2);
}); });
/** /**
* @tc.number : test_fileKey_007 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey titleOp * @tc.desc : filekey titleOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_007', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007', 0, async function (done) {
getFileAssetsBy(done, 'title'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007'
await getFileAssetsBy(done, testNum, 'title', 2);
}); });
/** /**
* @tc.number : test_fileKey_008 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey durationOp * @tc.desc : filekey durationOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_008', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008', 0, async function (done) {
getFileAssetsBy(done, 'duration'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008'
await getFileAssetsBy(done, testNum, 'duration');
}); });
/** /**
* @tc.number : test_fileKey_009 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey widthOp * @tc.desc : filekey widthOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_009', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009', 0, async function (done) {
getFileAssetsBy(done, 'width'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009'
await getFileAssetsBy(done, testNum, 'width');
}); });
/** /**
* @tc.number : test_fileKey_010 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey heightOp * @tc.desc : filekey heightOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_010', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010', 0, async function (done) {
getFileAssetsBy(done, 'height'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010'
await getFileAssetsBy(done, testNum, 'height');
}); });
/** /**
* @tc.number : test_fileKey_011 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey orientationOp * @tc.desc : filekey orientationOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_011', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011', 0, async function (done) {
getFileAssetsBy(done, 'orientation'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011'
await getFileAssetsBy(done, testNum, 'orientation', 2);
}); });
/** /**
* @tc.number : test_fileKey_012 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey widthOp * @tc.desc : filekey widthOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_012', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012', 0, async function (done) {
getFileAssetsBy(done, 'albumId'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012'
}); await getFileAssetsBy(done, testNum, 'albumId');
/**
* @tc.number : test_fileKey_0013
* @tc.name : getFileAssets
* @tc.desc : filekey albumNameOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('test_fileKey_0013', 0, async function (done) {
getFileAssetsBy(done, 'albumName');
}); });
/** /**
* @tc.number : test_fileKey_0014 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0014
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey artistOp * @tc.desc : filekey artistOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0014', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0014', 0, async function (done) {
getFileAssetsBy(done, 'artist'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014'
await getFileAssetsBy(done, testNum, 'artist');
}); });
/** /**
* @tc.number : test_fileKey_0015 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0015
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey audioAlbumOp * @tc.desc : filekey audioAlbumOp
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0015', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0015', 0, async function (done) {
getFileAssetsBy(done, 'audioAlbum'); let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015'
await getFileAssetsBy(done, testNum, 'audioAlbum');
}); });
/** /**
* @tc.number : test_fileKey_0016 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey relative_path * @tc.desc : filekey relative_path
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0016', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016', 0, async function (done) {
try { let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016'
let mediaType = mediaLibrary.MediaType.IMAGE; await getFileAssetsBy(done, testNum, 'relativePath');
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(DIR_IMAGE);
let fileAsset = await media.createAsset(mediaType, 'forRelative.jpg', path);
if (fileAsset == undefined) {
console.info('MediaLibraryTest : FETCHRESULT createAsset fail');
expect(false).assertTrue();
done();
return;
}
let fetchOption = {
selections: fileKeyObj.RELATIVE_PATH + '= ?',
selectionArgs: [path]
}
let fetchFileResult = await media.getFileAssets(fetchOption);
let firstObject = await fetchFileResult.getFirstObject();
expect(firstObject.relativePath == path).assertTrue();
done();
} catch (error) {
console.info('ASSET_CALLBACK test_fileKey_0016 failed, message = ' + error);
}
}); });
/** /**
* @tc.number : test_fileKey_0017 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0017
* @tc.name : getFileAssets * @tc.name : getFileAssets
* @tc.desc : filekey display_name * @tc.desc : filekey display_name
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0017', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0017', 0, async function (done) {
try { let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0017'
let mediaType = mediaLibrary.MediaType.IMAGE; await getFileAssetsBy(done, testNum, 'displayName');
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(DIR_IMAGE);
let name = 'forDisplay.jpg'
let fileAsset = await media.createAsset(mediaType, name, path);
if (fileAsset == undefined) {
console.info('MediaLibraryTest : FETCHRESULT createAsset fail');
expect(false).assertTrue();
done();
return;
}
let fetchOption = {
selections: fileKeyObj.DISPLAY_NAME + '= ?',
selectionArgs: [name]
}
let fetchFileResult = await media.getFileAssets(fetchOption);
let firstObject = await fetchFileResult.getFirstObject();
expect(firstObject.displayName == name).assertTrue();
done();
} catch (error) {
console.info('ASSET_CALLBACK test_fileKey_0017 failed, message = ' + error);
}
}); });
}); });
} }
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册