提交 41c86a5a 编写于 作者: Z zhangxingxia

update medialibrary xts

Signed-off-by: Nzhangxingxia <zhangxingxia1@huawei.com>
上级 880e0f50
{
"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"
}
......@@ -7,77 +7,47 @@
"shell-timeout": "600000"
},
"kits": [
{
"type": "ShellKit",
"pre-push": [
],
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/*",
"mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA"
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/medialibrary/01.jpg ->/storage/media/100/local/files",
"./resource/medialibrary/01.mp3 ->/storage/media/100/local/files",
"./resource/medialibrary/01.mp4 ->/storage/media/100/local/files",
"./resource/medialibrary/test.dat ->/storage/media/100/local/files",
"./resource/medialibrary/test2.dat ->/storage/media/100/local/files"
"./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"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir /storage/media/100/local/files/Pictures",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/02.jpg",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/03.jpg",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/02.mp3",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/03.mp3",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/02.mp4",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/03.mp4",
"mkdir /storage/media/100/local/files/Pictures/weixin",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/weixin",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/weixin",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/weixin",
"mkdir /storage/media/100/local/files/Camera",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Camera/01.jpg",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Camera/02.jpg",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Camera/01.mp3",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Camera/02.mp3",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Camera/01.mp4",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Camera/02.mp4",
"mkdir /storage/media/100/local/files/Documents",
"cp /storage/media/100/local/files/test.dat /storage/media/100/local/files/Documents/test.dat",
"cp /storage/media/100/local/files/test2.dat /storage/media/100/local/files/Documents/test2.dat",
"mkdir /storage/media/100/local/files/Pictures/DeleteAlbumPro",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/DeleteAlbumPro",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/DeleteAlbumPro",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/DeleteAlbumPro",
"mkdir /storage/media/100/local/files/Pictures/DeleteAlbumCallback",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/DeleteAlbumCallback",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/DeleteAlbumCallback",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/DeleteAlbumCallback",
"mkdir /storage/media/100/local/files/Pictures/AblumInfo",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/AblumInfo",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/AblumInfo",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/AblumInfo",
"mkdir /storage/media/100/local/files/Pictures/FileAssetTest",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/FileAssetTest",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/FileAssetTest/02.jpg",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/FileAssetTest",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/FileAssetTest/02.mp3",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/FileAssetTest",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/FileAssetTest/02.mp4",
"mkdir /storage/media/100/local/files/Pictures/MediaLibraryTest",
"cp /storage/media/100/local/files/01.jpg /storage/media/100/local/files/Pictures/MediaLibraryTest",
"cp /storage/media/100/local/files/01.mp3 /storage/media/100/local/files/Pictures/MediaLibraryTest",
"cp /storage/media/100/local/files/01.mp4 /storage/media/100/local/files/Pictures/MediaLibraryTest",
"cp /storage/media/100/local/files/test.dat /storage/media/100/local/files/Pictures/MediaLibraryTest",
"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 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;",
"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"
],
"teardown-command":[
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/*"
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA",
"sleep 20"
]
},
{
......
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.
* 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,12 +12,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
@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()
})
}
};
\ No newline at end of file
.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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
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'
......
/*
* 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
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';
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
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';
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
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';
......@@ -40,7 +40,7 @@ function checkAttrs(done, asset, tNum) {
done();
}
}
describe('fileAssetPromise2.test.js', async function () {
describe('fileAsset2.test.js', async function () {
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
......
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility'
import fileio from '@ohos.fileio';
import {describe, it, expect} from 'deccjsunit/index';
export default function fileAssetUriTestCallBackTest(abilityContext){
describe('fileAssetUriTestCallBackTest', function() {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(abilityContext);
console.info('MediaLibraryTest : getMediaLibrary OUT');
const fileKeyObj = mediaLibrary.FileKey;
//======================== FILE BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35
* @tc.name : close
* @tc.desc : asset close the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35', 0, async function(done) {
let asset;
let fd;
let fd1;
try {
let type = mediaLibrary.MediaType.IMAGE;
let fetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ type.toString() ],
};
const fetchFileResult = await media.getFileAssets(fetchOp);
expect(fetchFileResult != undefined).assertTrue();
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 uri:'
+ uri);
const serachUri = 'dataability:///media/image/' + id;
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 serachUri:'
+ serachUri);
let serchfetchOp = {
uri:serachUri.toString(),
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ type.toString()],
};
const result = await media.getFileAssets(serchfetchOp);
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 getFileAssets by uri:'
+ serachUri + ",result.getCount():" + result.getCount());
asset = await result.getFirstObject();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 asset.uri:'
+ asset.uri);
expect(asset.uri == serachUri).assertTrue();
fd = await asset.open('r');
expect(fd > 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 fd:' + fd);
asset.close(fd, async (error) => {
fd1 = await asset.open('r');
expect(fd1 > 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 fd1:'
+ fd1);
await asset.close(fd1);
done();
});
} catch (error) {
console.info(
`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 error:${error}`);
expect(false).assertTrue();
done();
}
});
//======================== CLOSE BEGIN ================================
});
}
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility'
import fileio from '@ohos.fileio';
import {describe, it, expect} from 'deccjsunit/index';
export default function fileAssetUriTestPromiseTest(abilityContext){
describe('fileAssetUriTestPromiseTest', function() {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(abilityContext);
console.info('MediaLibraryTest : getMediaLibrary OUT');
const fileKeyObj = mediaLibrary.FileKey;
//======================== FILE BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35
* @tc.name : close
* @tc.desc : asset close the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35', 0, async function(done) {
let asset;
let fd;
let fd1;
try {
let type = mediaLibrary.MediaType.IMAGE;
let fetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ type.toString() ],
};
const fetchFileResult = await media.getFileAssets(fetchOp);
expect(fetchFileResult != undefined).assertTrue();
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 uri:' + uri);
const serachUri = 'dataability:///media/image/' + id;
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 serachUri:'
+ serachUri);
let serchfetchOp = {
uri : serachUri.toString(),
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ type.toString() ],
};
const result = await media.getFileAssets(serchfetchOp);
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 getFileAssets by uri:'
+ serachUri + ",result.getCount():" + result.getCount());
asset = await result.getFirstObject();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 asset.uri:'
+ asset.uri);
expect(asset.uri == serachUri).assertTrue();
fd = await asset.open('r');
expect(fd > 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 fd:' + fd);
await asset.close(fd);
fd1 = await asset.open('r');
expect(fd1 > 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 fd1:' + fd1);
await asset.close(fd1);
done();
} catch (error) {
console.info(
`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_PROMISE_005_35 error:${error}`);
expect(false).assertTrue();
done();
}
});
//======================== CLOSE BEGIN ================================
});
}
......@@ -17,9 +17,10 @@ import { describe, beforeAll,afterAll, it, expect } from 'deccjsunit/index';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundle from '@ohos.bundle';
describe("get_permission", function () {
export default function getPermissionTest() {
describe("get_permission", function () {
/**
/**
* @tc.number SUB_DF_GRANT_USER_GRANTED_PERMISSION_0000
* @tc.name grant_user_granted_permission_async_000
* @tc.desc Test grantUserGrantedPermission() interfaces, grant permission.
......@@ -28,18 +29,19 @@ describe("get_permission", function () {
* @tc.level Level 0
* @tc.require
*/
it("grant_user_granted_permission_async_000", 0, async function (done) {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.mediaLibrary', 0, 100);
let tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let result1 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION",1);
let result2 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA",1);
let result3 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_MEDIA",1);
let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION");
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA");
expect(result1 == 0 && result2 == 0 && result3 == 0).assertTrue();
expect(isGranted1 == 0 && isGranted2 == 0 && isGranted3 == 0).assertTrue();
done();
it("grant_user_granted_permission_async_000", 0, async function (done) {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.mediaLibrary', 0, 100);
let tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let result1 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION", 1);
let result2 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA", 1);
let result3 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_MEDIA", 1);
let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION");
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA");
expect(result1 == 0 && result2 == 0 && result3 == 0).assertTrue();
expect(isGranted1 == 0 && isGranted2 == 0 && isGranted3 == 0).assertTrue();
done();
});
});
});
\ No newline at end of file
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册