提交 a24f5b51 编写于 作者: Z zhang-daiyue

Add medialibrary xts test cases.

Signed-off-by: Nzhang-daiyue <zhangdaiyue1@huawei.com>
Change-Id: I00227d6fb8425d4b6832ef9675e36fc678ee42fd
上级 aa365bff
/*
* 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.
*/
require('./favoriteTestCallBack.test.js')
require('./fileTestPromise.test.js')
require('./favoriteTestPromise.test.js')
require('./fileAsset2.test.js')
require('./fileAssetTestPromise.test.js')
require('./mediaLibraryTestPromise.test.js')
require('./albumGetFileAssetsPromise.test.js')
require('./albumTestPromise.test.js')
/*
* 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.
*/
require('./FileAssetGetThumbnailCallBack.test.js')
require('./FileAssetGetThumbnailPromise.test.js')
require('./albumGetFileAssetsPromise.test.js')
require('./albumTestCallBack.test.js')
require('./albumTestPromise.test.js')
require('./distributed.test.js')
require('./favoriteTestCallBack.test.js')
require('./favoriteTestPromise.test.js')
require('./fetchFileResultCallBack.test.js')
require('./fetchFileResultPromise.test.js')
require('./fileAsset2.test.js')
require('./fileAssetTestPromise.test.js')
require('./fileAssetUriTestCallBack.test.js')
require('./fileTestCallBack.test.js')
require('./fileTestPromise.test.js')
require('./filekeyTestPromise.test.js')
require('./getAllPeersDeviceTestPromise.test.js')
require('./getAllPeersTestPromise.test.js')
require('./mediaLibraryTestPromise.test.js')
require('./mediaLibraryTestPromiseOnOff.test.js')
require('./favtrashTestCallBack.test.js')
require('./favtrashTestPromise.test.js')
......@@ -16,7 +16,7 @@ import mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
describe('fileAssetTestPromise.test.js', async function () {
describe('albumGetFileAssetsPromise.test.js', async function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
......
......@@ -75,7 +75,7 @@ function checkAlbumAttr(done, album) {
}
}
describe('album.promise.test.js', async function () {
describe('albumTestPromise.test.js', async function () {
var context = featureAbility.getContext();
var media = mediaLibrary.getMediaLibrary(context);
beforeAll(function () {});
......@@ -392,9 +392,7 @@ describe('album.promise.test.js', async function () {
};
try {
const albumList = await media.getAlbums(fileHasArgsfetchOp3);
console.info(
'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06 length:' + albumList.length
);
console.info('GETALBUMASSETS_PROMISE_002_06 length:' + albumList.length);
expect(albumList.length == 0).assertTrue();
done();
} catch (error) {
......@@ -419,9 +417,7 @@ describe('album.promise.test.js', async function () {
};
try {
const albumList = await media.getAlbums(fileHasArgsfetchOp4);
console.info(
'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07 length:' + albumList.length
);
console.info('GETALBUMASSETS_PROMISE_002_07 length:' + albumList.length);
expect(albumList.length == 0).assertTrue();
done();
} catch (error) {
......@@ -447,9 +443,7 @@ describe('album.promise.test.js', async function () {
try {
const albumList = await media.getAlbums(fileHasArgsfetchOp5);
console.info(
'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08 length:' + albumList.length
);
console.info('GETALBUMASSETS_PROMISE_002_08 length:' + albumList.length);
expect(albumList.length == 0).assertTrue();
done();
} catch (error) {
......
/*
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('Create_File_Assets.test.js', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
beforeAll(function () {
onsole.info('MediaLibraryTest: beforeAll');
})
beforeEach(function () {
console.info('MediaLibraryTest: beforeEach');
})
afterEach(function () {
console.info('MediaLibraryTest: afterEach');
})
afterAll(function () {
console.info('MediaLibraryTest: afterAll');
console.info('MediaLibraryTest : createAsset : release begin');
if (media != undefined) {
media.release();
}
console.info('MediaLibraryTest : createAsset : release end');
})
/**
* @tc.number : 01
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01
* @tc.desc : Create an image file asset in predefined relative path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01', 0, async function (done) {
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayName = "02image.jpg";
let rp = "Pictures/";
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => {
if (fileObj != undefined) {
console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS');
expect(true).assertTrue();
done();
} else {
console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL');
expect(false).assertTrue();
done();
}
});
console.info('MediaLibraryTest : createAsset end');
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 end');
/**
* @tc.number : 02
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02
* @tc.desc : Create an image file asset in not predefined relative path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02', 0, async function (done) {
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayName = "02image.jpg";
let rp = "Pictures/test/001/";
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => {
if (fileObj != undefined) {
console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : PASS');
expect(true).assertTrue();
done();
} else {
console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : FAIL');
expect(false).assertTrue();
done();
}
});
console.info('MediaLibraryTest : createAsset end');
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 end');
/**
* @tc.number : 03
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03
* @tc.desc : Repeat to create same image file asset expect return error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03', 0, async function (done) {
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayName = "02image.jpg";
let rp = "Pictures/test/001/";
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => {
if (fileObj == undefined) {
console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : PASS');
expect(true).assertTrue();
done();
}
console.info('MediaLibraryTest : createAsset : FAIL');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : FAIL');
expect(false).assertTrue();
done();
});
console.info('MediaLibraryTest : createAsset end');
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 end');
/**
* @tc.number : 04
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04
* @tc.desc : Create image file asset in invalid relative path expect return error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04', 0, async function (done) {
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayName = "04image.jpg";
let rp = "test/";
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => {
if (createAssetErr != undefined) {
console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : PASS');
expect(true).assertTrue();
done();
}
console.info('MediaLibraryTest : createAsset : FAIL');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : FAIL');
expect(false).assertTrue();
done();
});
console.info('MediaLibraryTest : createAsset end');
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 end');
/**
* @tc.number : 07
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07
* @tc.desc : After create an image file asset, open and close it
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07', 0, async function (done) {
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayName = "03image.jpg";
media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (err, rp) => {
if (rp != undefined) {
console.info('MediaLibraryTest : getPublicDirectory Successfull ' + rp);
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp, (createAssetErr, data) => {
if (data != undefined) {
console.info('MediaLibraryTest : createAsset Successfull ');
getObjectInfo(data);
} else {
console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL');
expect(false).assertTrue();
done();
}
});
console.info('MediaLibraryTest : createAsset end');
} else {
console.info('MediaLibraryTest : getPublicDirectory : FAIL');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL');
expect(false).assertTrue();
done();
}
});
}
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 end');
});
function getObjectInfo(fileAsset) {
console.info('MediaLibraryTest : getObjectInfo uri is ' + fileAsset.uri);
console.info("==========================fileAsset.open begin=======================>");
fileAsset.open('Rw').then((openError, fd) => {
if (openError == undefined) {
console.info('MediaLibraryTest : open : FAIL ' + openError.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL');
expect(false).assertTrue();
done();
}
console.info("==========================fileAsset.open success=======================>");
console.debug("open success fd = " + JSON.stringify(fd));
console.info("==========================fileAsset.close begin=======================>");
fileAsset.close(fd).then((closeErr) => {
if (closeErr == undefined) {
console.info('MediaLibraryTest : close : FAIL ' + closeErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL');
expect(false).assertTrue();
done();
}
console.info("==========================fileAsset.close success=======================>");
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : PASS');
expect(true).assertTrue();
done();
});
console.info("==========================fileAsset.close end=======================>");
});
console.info("==========================fileAsset.open end=======================>");
}
});
\ 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 mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('createFileAssetsPerformance.test.js', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
let times = 100;
beforeAll(function () {
onsole.info('MediaLibraryTest: beforeAll');
})
beforeEach(function () {
console.info('MediaLibraryTest: beforeEach');
})
afterEach(function () {
console.info('MediaLibraryTest: afterEach');
})
afterAll(function () {
console.info('MediaLibraryTest: afterAll');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin');
it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01', 0, async function (done) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin1');
if (media == null || media == undefined) {
console.info('MediaLibraryTest : media == null');
} else {
let mediaType = mediaLibrary.MediaType.IMAGE;
let displayNamePrefix = "image";
let extendStr = ".jpg"
let rp = "Pictures/";
let displayName;
let conteEnd = 0;
for (let i = 0; i < times; i++) {
displayName = displayNamePrefix + i + extendStr;
console.info('MediaLibraryTest : createAsset begin');
media.createAsset(mediaType, displayName, rp).then((fileObj) => {
if (fileObj != undefined) {
console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri);
conteEnd++;
if (conteEnd == times) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : PASS');
expect(true).assertTrue();
done();
} else if (i == times) {
console.info('MediaLibraryTest : createAsset has error');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 :Partial success');
expect(false).assertTrue();
done();
}
} else {
console.info('MediaLibraryTest : createAsset Unsuccessfull ');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : FAIL');
expect(false).assertTrue();
done();
}
});
console.info('MediaLibraryTest : createAsset end');
}
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 end');
});
\ 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 mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('deleteFileAssetsPerformance.test.js', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
let fileList_;
let fileKeyObj = mediaLibrary.FileKey
let type = mediaLibrary.MediaType.IMAGE
let fetchOp = {
selections: fileKeyObj.MEDIA_TYPE + " = ? ",
selectionArgs: [type.toString()],
order: fileKeyObj.DATE_ADDED,
}
beforeAll(function () {
onsole.info('MediaLibraryTest: beforeAll');
})
beforeEach(function () {
console.info('MediaLibraryTest: beforeEach');
})
afterEach(function () {
console.info('MediaLibraryTest: afterEach');
})
afterAll(function () {
console.info('MediaLibraryTest: afterAll');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 begin');
it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01', 0, async function (done) {
media.getFileAssets(fetchOp, (getFileAssetsErr, queryResultSet) => {
if (queryResultSet != undefined) {
console.info('MediaLibraryTest : getAllObject Successfull ' + queryResultSet.getCount());
if (queryResultSet.getCount() > 0) {
queryResultSet.getAllObject((getAllObjectErr, fileList) => {
if (fileList != undefined) {
fileList_ = fileList;
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :PASS');
expect(true).assertTrue();
done();
} else {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :FAIL'
+ getAllObjectErr.message);
expect(false).assertTrue();
done();
}
});
} else {
console.info('MediaLibraryTest : getFileAssets :No data');
expect(true).assertTrue();
done();
}
} else {
console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + getFileAssetsErr.message);
console.info('MediaLibraryTest : getFileAssets :FAIL');
expect(false).assertTrue();
done();
}
});
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 end');
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_ASSET_01
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 begin');
it('SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01', 0, async function (done) {
if (fileList_ != undefined) {
let counteEnd = 0;
for (let i = 0; i < fileList_.length; i++) {
let fileAsset = fileList_[i];
console.info('MediaLibraryTest : uri is ' + fileAsset.uri);
media.deleteAsset(fileAsset.uri, (deleteAssetErr, deleteRows) => {
if (deleteRows >= 0) {
console.info('MediaLibraryTest : Delete Asset Successfull ' + deleteRows);
counteEnd++;
if (counteEnd == fileList_.length) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 : PASS');
expect(true).assertTrue();
done();
} else if (i == fileList_.length - 1) {
console.info('MediaLibraryTest : delete has error');
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :Partial success');
expect(false).assertTrue();
done();
}
} else {
console.info('MediaLibraryTest : delete error ' + deleteAssetErr.message);
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL');
expect(false).assertTrue();
done();
}
});
}
} else {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL'
+ getAllObjectErr.message);
expect(false).assertTrue();
done();
}
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 end');
});
\ 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 mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('getAlbumsPerformance.test.js', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
let times = 25;
let AlbumNoArgsfetchOp = {
selections: "",
selectionArgs: [""],
}
beforeAll(function () {
onsole.info('MediaLibraryTest: beforeAll');
})
beforeEach(function () {
console.info('MediaLibraryTest: beforeEach');
})
afterEach(function () {
console.info('MediaLibraryTest: afterEach');
})
afterAll(function () {
console.info('MediaLibraryTest: afterAll');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 begin');
it('SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01', 0, async function (done) {
for (let i = 0; i < times; i++) {
const albumArray = await media.getAlbums(AlbumNoArgsfetchOp);
if (albumArray != undefined) {
console.info('MediaLibraryTest : getAlbums : PASS ' + albumArray.length);
expect(true).assertTrue();
} else {
console.info('MediaLibraryTest : getAlbums : FAIL');
expect(false).assertTrue();
}
}
console.info('MediaLibraryTest : for : end');
done();
});
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 end');
});
\ 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 image from '@ohos.multimedia.image';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
} from 'deccjsunit/index'
describe('distributed.promise.test.js', function () {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
beforeAll(function () {
onsole.info('Distributed. Promise MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.');
})
beforeEach(function () {
console.info('Distributed. Promise MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.');
})
afterEach(function () {
console.info('Distributed. Promise MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.');
})
afterAll(function () {
console.info('Distributed. Promise MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_distributed_001_01
* @tc.name : getActivePeers
* @tc.desc : getActivePeers
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01', 0, async function (done) {
try {
done();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 begin');
let peers = await media.getActivePeers();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 done');
done();
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 fail, message = ' + error);
done();
}
done();
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02
* @tc.name : getAllPeers
* @tc.desc : getAllPeers
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02', 0, async function (done) {
try {
done();
let peers = await media.getAllPeers();
done();
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02 fail, message = ' + error);
done();
}
done();
});
})
\ 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 mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('favSmartAlbum.promise.test.js', function () {
let mediaType = mediaLibrary.MediaType.IMAGE;
let path = "Pictures/"
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
var asset;
var favSmartAlbum;
beforeAll(function () {
console.info('Smart Album Callback MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.');
})
beforeEach(function () {
console.info('Smart Album Callback MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.');
})
afterEach(function () {
console.info('Smart Album Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.');
})
afterAll(function () {
console.info('Smart Album Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001
* @tc.name : Get PrivateSmartAlbum by fav
* @tc.desc : Get PrivateSmartAlbum by fav
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001', 0, async function (done) {
try {
asset = await media.createAsset(mediaType, "imagefavtest.jpg", path);
media.getPrivateAlbum(mediaLibrary.PrivateAlbumType.TYPE_FAVORITE, getPrivateAlbumCallBack);
done();
} catch (error) {
console.info('MediaLibraryTest : CALLBACK_001 getPrivateAlbum fail, message = ' + error);
done();
}
});
function getPrivateAlbumCallBack(err, favSmartAlbums) {
if (favSmartAlbums != undefined) {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbum favSmartAlbums');
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums ' + favSmartAlbums[0].albumName);
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums ' + favSmartAlbums[0].albumCapacity);
favSmartAlbum = favSmartAlbums[0];
favSmartAlbum.addAsset(asset.uri, addAssetCallBack);
done();
} else {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack Unsuccessfull ' + err);
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack : FAIL');
done();
}
}
function addAssetCallBack(err, data) {
if (data != undefined) {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK fav addAsset success');
favSmartAlbum.getFileAssets(getFileAssetsCallBack);
favSmartAlbum.removeAsset(asset.uri, removeAssetCallBack);
done();
} else {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack Unsuccessfull ' + err);
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack : FAIL');
done();
}
}
function removeAssetCallBack(err, data) {
if (data != undefined) {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK fav removeAsset success');
favSmartAlbum.getFileAssets(getFileAssetsCallBack);
done();
} else {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK removeAssetCallBack Unsuccessfull ' + err);
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateremoveAssetCallBackAlbumCallBack : FAIL');
done();
}
}
function getFileAssetsCallBack(err, fSmartFetchFileResult) {
if (fSmartFetchFileResult != undefined) {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Successfull fSmartFetchFileResult = ' +
fSmartFetchFileResult.getCount());
done();
} else {
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Unsuccessfull ' + err);
console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack : FAIL');
done();
}
}
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册