提交 f9a43d23 编写于 作者: P panqiangbiao

update medialibrary to stage

Signed-off-by: Npanqiangbiao <panqiangbiao@huawei.com>
上级 865a5040
{
"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.
# 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
......@@ -12,27 +12,29 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("mediaLibrary_js_hap") {
hap_profile = "./src/main/config.json"
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryJsTest"
}
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
ohos_app_scope("medialibrary_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("mediaLibrary_js_assets") {
source_dir = "./src/main/js/default"
source_dir = "entry/src/main/ets"
}
ohos_resources("mediaLibrary_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
sources = [ "entry/src/main/resources" ]
deps = [ ":medialibrary_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
......@@ -13,9 +13,9 @@
],
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/*",
"rm -rf /data/accounts/account_0/appdata/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.MediaLibraryDataA"
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
]
},
{
......@@ -23,31 +23,32 @@
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA"
"./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,Static01,Album/Static,SR001PRO,SR001CB,Dynamic,Dynamic01,Dynamic02,Dynamic022,DeleteCb01,AblumInfo,DeletePro01,Delete01,Temp},Videos/{Static,Static01,Album/Static,SR001PRO,SR001CB,Dynamic,Dynamic01,Dynamic02,DeleteCb01,AblumInfo,DeletePro01,Delete01},Audios/{Static,Static01,Album/Static,SR001PRO,SR001CB,Dynamic,Dynamic01,Dynamic02,DeleteCb01,AblumInfo,DeletePro01,Delete01},Documents/{Static,Static01,Album/Static,SR001PRO,SR001CB,Dynamic,Dynamic01,Dynamic02,DeleteCb01,AblumInfo,DeletePro01,Delete01}}",
"for d in Static Album/Static Dynamic Dynamic01 Dynamic022 AblumInfo; do for i in $$(seq 3); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $$(seq 3); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $$(seq 3); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in Static Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $$(seq 3); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"for d in Static Album/Static Dynamic Dynamic01 Dynamic022 AblumInfo; do for i in $(seq 3); 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 Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $(seq 3); 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 Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $(seq 3); 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 Album/Static Dynamic Dynamic01 Dynamic02 AblumInfo; do for i in $(seq 3); 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 SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.jpg /storage/media/100/local/files/Pictures/$$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.mp3 /storage/media/100/local/files/Audios/$$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.mp4 /storage/media/100/local/files/Videos/$$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/01.dat /storage/media/100/local/files/Documents/$$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$d ;done;",
"for d in SR001PRO SR001CB DeleteCb01 DeletePro01 Static01; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$d ;done;",
"chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"killall com.ohos.medialibrary.MediaScannerAbilityA",
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA",
"sleep 20"
"aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"sleep 60",
"sleep 60",
"sleep 60"
]
},
{
......
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.ets"
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) 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 getPermissionTest from './getPermission.test.ets'
import albumGetFileAssetsCallbackTest from './albumGetFileAssetsCallback.test.ets'
import albumGetFileAssetsPromiseTest from './albumGetFileAssetsPromise.test.ets'
import favoriteTestCallBackTest from './favoriteTestCallBack.test.ets'
import favoriteTestPromiseTest from './favoriteTestPromise.test.ets'
import fetchFileResultCallBackTest from './fetchFileResultCallBack.test.ets'
import fetchFileResultPromiseTest from './fetchFileResultPromise.test.ets'
import fileAssetCallBack2Test from './fileAssetCallBack2.test.ets'
import FileAssetGetThumbnailCallBackTest from './FileAssetGetThumbnailCallBack.test.ets'
import FileAssetGetThumbnailPromiseTest from './FileAssetGetThumbnailPromise.test.ets'
import fileAssetPromise2Test from './fileAssetPromise2.test.ets'
import fileAssetTestCallbackTest from './fileAssetTestCallback.test.ets'
import fileAssetTestPromiseTest from './fileAssetTestPromise.test.ets'
import fileAssetUriTestCallBackTest from './fileAssetUriTestCallBack.test.ets'
import fileAssetUriTestPromiseTest from './fileAssetUriTestPromise.test.ets'
import filekeyTestCallBackTest from './filekeyTestCallBack.test.ets'
import filekeyTestPromiseTest from './filekeyTestPromise.test.ets'
import fileTestCallBackTest from './fileTestCallBack.test.ets'
import fileTestPromiseTest from './fileTestPromise.test.ets'
import mediaLibraryTestCallBackTest from './mediaLibraryTestCallBack.test.ets'
import mediaLibraryTestPromiseTest from './mediaLibraryTestPromise.test.ets'
import albumTestCallBackTest from './albumTestCallBack.test.ets'
import albumTestPromiseTest from './albumTestPromise.test.ets'
import mediaLibraryTestPromiseOnOffTest from './mediaLibraryTestPromiseOnOff.test.ets'
export default function testsuite(abilityContext) {
getPermissionTest()
albumGetFileAssetsCallbackTest(abilityContext)
albumGetFileAssetsPromiseTest(abilityContext)
favoriteTestCallBackTest(abilityContext)
favoriteTestPromiseTest(abilityContext)
fetchFileResultCallBackTest(abilityContext)
fetchFileResultPromiseTest(abilityContext)
fileAssetCallBack2Test(abilityContext)
FileAssetGetThumbnailCallBackTest(abilityContext)
FileAssetGetThumbnailPromiseTest(abilityContext)
fileAssetPromise2Test(abilityContext)
fileAssetTestCallbackTest(abilityContext)
fileAssetTestPromiseTest(abilityContext)
fileAssetUriTestCallBackTest(abilityContext)
fileAssetUriTestPromiseTest(abilityContext)
filekeyTestCallBackTest(abilityContext)
filekeyTestPromiseTest(abilityContext)
fileTestCallBackTest(abilityContext)
fileTestPromiseTest(abilityContext)
mediaLibraryTestCallBackTest(abilityContext)
mediaLibraryTestPromiseTest(abilityContext)
albumTestCallBackTest(abilityContext)
albumTestPromiseTest(abilityContext)
mediaLibraryTestPromiseOnOffTest(abilityContext)
}
\ 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
export default function albumGetFileAssetsPromiseTest(abilityContext) {
describe('albumGetFileAssetsPromiseTest', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(abilityContext);
console.info('MediaLibraryTest : getMediaLibrary OUT');
beforeAll(function () {
});
beforeEach(function () {
});
afterEach(function () {
});
afterAll(function () {
});
const fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
const count = 3;
const countOne = 1;
let allTypefetchOp = {
selections: '',
selectionArgs: [],
};
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01
* @tc.name : getFileAssets
* @tc.desc : more file type all
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01', 0, async function (done) {
try {
let allTypefetchOp = {
selections: fileKeyObj.ALBUM_NAME + '= ? ',
selectionArgs: ['AblumInfo'],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(allTypefetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02
* @tc.name : getFileAssets
* @tc.desc : more file type image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02', 0, async function (done) {
try {
let imageAlbumfetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'Static', imageType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03
* @tc.name : getFileAssets
* @tc.desc : more file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03', 0, async function (done) {
try {
let audioAlbumfetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Audios/', 'Static', audioType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(audioAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04
* @tc.name : getFileAssets
* @tc.desc : more file type video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04', 0, async function (done) {
try {
let videoAlbumfetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Videos/', 'Static', videoType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05
* @tc.name : getFileAssets
* @tc.desc : more file type image and video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05', 0, async function (done) {
try {
let imageAndVideoAlbumfetchOp = {
selections: '(' + fileKeyObj.RELATIVE_PATH + '= ? or ' + fileKeyObj.RELATIVE_PATH + '= ? ) AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'Videos/', 'AblumInfo', imageType.toString(), videoType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAndVideoAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06
* @tc.name : getFileAssets
* @tc.desc : more file type image and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06', 0, async function (done) {
try {
let imageAndAudioAlbumfetchOp = {
selections: '(' + fileKeyObj.RELATIVE_PATH + '= ? or ' + fileKeyObj.RELATIVE_PATH + '= ? ) AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'Audios/', 'AblumInfo', imageType.toString(), audioType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAndAudioAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/** order: 'date_added DESC LIMIT 0,500'
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07
* @tc.name : getFileAssets
* @tc.desc : more file type video and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07', 0, async function (done) {
try {
let videoAndAudioAlbumfetchOp = {
selections: '(' + fileKeyObj.RELATIVE_PATH + '= ? or ' + fileKeyObj.RELATIVE_PATH + '= ? ) AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Videos/', 'Audios/', 'AblumInfo', audioType.toString(), videoType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAndAudioAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_08
* @tc.name : getFileAssets
* @tc.desc : more file type image video and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_08', 0, async function (done) {
try {
let imgAndVideoAndAudioAlbumfetchOp = {
selections: '(' + fileKeyObj.RELATIVE_PATH + '= ? or ' + fileKeyObj.RELATIVE_PATH + '= ? or ' + fileKeyObj.RELATIVE_PATH + '= ? ) AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'Videos/', 'Audios/', 'AblumInfo', imageType.toString(), videoType.toString(), audioType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imgAndVideoAndAudioAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_09
* @tc.name : getFileAssets
* @tc.desc : one file tpe image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_09', 0, async function (done) {
try {
let albumfetchOpOne = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(albumfetchOpOne);
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_10
* @tc.name : getFileAssets
* @tc.desc : one file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_10', 0, async function (done) {
try {
let albumfetchOpOne = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(albumfetchOpOne);
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_11
* @tc.name : getFileAssets
* @tc.desc : one file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_11', 0, async function (done) {
try {
let albumfetchOpOne = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(albumfetchOpOne);
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12
* @tc.name : getFileAssets
* @tc.desc : no file type image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12', 0, async function (done) {
try {
let albumfetchOpNone = {
selections: fileKeyObj.MEDIA_TYPE + '= ? AND date_added < 0',
selectionArgs: [imageType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpNone);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12 done');
done();
} catch (error) {
expect(false).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12 error:' + error);
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13
* @tc.name : getFileAssets
* @tc.desc : no file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13', 0, async function (done) {
try {
let albumfetchOpNone = {
selections: fileKeyObj.MEDIA_TYPE + '= ? AND date_added < 0',
selectionArgs: [audioType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpNone);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13 done');
done();
} catch (error) {
expect(false).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13 error:' + error);
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14
* @tc.name : getFileAssets
* @tc.desc : no file type video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14', 0, async function (done) {
try {
let albumfetchOpNone = {
selections: fileKeyObj.MEDIA_TYPE + '= ? AND date_added < 0',
selectionArgs: [videoType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpNone);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14 done');
done();
} catch (error) {
expect(false).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13 error:' + error);
done();
}
});
});
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain"
},
{
"name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册