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

!2651 udpate xts

Merge pull request !2651 from 潘强标/master
/*
* 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('./getPermission.test.js')
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')
/*
* 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('./getPermission.test.js')
require('./albumGetFileAssetsCallback.test.js')
require('./albumGetFileAssetsPromise.test.js')
require('./distributedCallback.test.js')
require('./distributedPromise.test.js')
require('./favoriteTestCallBack.test.js')
require('./favoriteTestPromise.test.js')
require('./fetchFileResultCallBack.test.js')
require('./fetchFileResultPromise.test.js')
require('./fileAssetCallBack2.test.js')
require('./FileAssetGetThumbnailCallBack.test.js')
require('./FileAssetGetThumbnailPromise.test.js')
require('./fileAssetPromise2.test.js')
require('./fileAssetTestCallback.test.js')
require('./fileAssetTestPromise.test.js')
require('./fileAssetUriTestCallBack.test.js')
require('./fileAssetUriTestPromiese.test.js')
require('./filekeyTestCallBack.test.js')
require('./filekeyTestPromise.test.js')
require('./fileTestCallBack.test.js')
require('./fileTestPromise.test.js')
require('./getAllPeersDeviceTestCallback.test.js')
require('./getAllPeersDeviceTestPromise.test.js')
require('./getAllPeersTestCallback.test.js')
require('./getAllPeersTestPromise.test.js')
require('./mediaLibraryTestCallBack.test.js')
require('./mediaLibraryTestPromise.test.js')
require('./mediaLibraryTestPromiseOnOff.test.js')
require('./albumTestCallBack.test.js')
require('./albumTestPromise.test.js')
/*
* 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';
describe('albumGetFileAssetsCallback.test.js', async function() {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
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;
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_01', 0, async function(done) {
try {
let allTypefetchOp = {
selections : '',
selectionArgs : [],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(allTypefetchOp);
const album = albumList[0];
album.getFileAssets(allTypefetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_02', 0, async function(done) {
try {
let imageAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ imageType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(imageAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_03', 0, async function(done) {
try {
let audioAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ audioType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(audioAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(audioAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_04', 0, async function(done) {
try {
let videoAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ videoType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(videoAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_05', 0, async function(done) {
try {
let imageAndVideoAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ imageType.toString(), videoType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAndVideoAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(imageAndVideoAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_06', 0, async function(done) {
try {
let imageAndAudioAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ imageType.toString(), audioType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAndAudioAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(imageAndAudioAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
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_CALLBACK_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_CALLBACK_001_07', 0, async function(done) {
try {
let videoAndAudioAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ videoType.toString(), audioType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAndAudioAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(videoAndAudioAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_001_08', 0, async function(done) {
try {
let imgAndVideoAndAudioAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ? or '
+ fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ imageType.toString(), videoType.toString(), audioType.toString() ],
order : 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imgAndVideoAndAudioAlbumfetchOp);
const album = albumList[0];
album.getFileAssets(imgAndVideoAndAudioAlbumfetchOp, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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];
album.getFileAssets(albumfetchOpOne, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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];
album.getFileAssets(albumfetchOpOne, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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];
album.getFileAssets(albumfetchOpOne, (error, fetchFileResult) => {
if (fetchFileResult == undefined) {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
done();
}
});
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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',
};
media.getAlbums(albumfetchOpNone, (error, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_12 albumList == undefined');
done();
} else {
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_12 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_12 done');
done();
}
});
} catch (error) {
expect(false).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_12 error:' + error);
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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',
};
media.getAlbums(albumfetchOpNone, (error, albumList) => {
if (albumList == undefined) {
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_13 albumList == undefined');
expect(false).assertTrue();
done();
} else {
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_13 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
done();
}
});
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_13 error:' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_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_CALLBACK_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',
};
media.getAlbums(albumfetchOpNone, (error, albumList) => {
if (albumList == undefined) {
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_14 albumList == undefined');
expect(false).assertTrue();
done();
} else {
console.info(
'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_14 albumList.length:'
+ albumList.length);
expect(albumList.length == 0).assertTrue();
done();
}
});
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_14 error:' + error);
expect(false).assertTrue();
done();
}
});
});
\ 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('distributedCallback.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. Callback MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.');
})
beforeEach(function() {
console.info(
'Distributed. Callback MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.');
})
afterEach(function() {
console.info(
'Distributed. Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.');
})
afterAll(function() {
console.info(
'Distributed. Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed');
})
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_01
* @tc.name : getActivePeers
* @tc.desc : getActivePeers
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_01', 0, async function(done) {
try {
done();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_01 begin');
media.getActivePeers((error, peers) => {
expect(error == undefined).assertTrue();
});
done();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_01 done');
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_01 fail, message = '
+ error);
done();
}
done();
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_02
* @tc.name : getAllPeers
* @tc.desc : getAllPeers
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_02', 0, async function(done) {
try {
done();
media.getAllPeers((error, peers) => {
expect(error == undefined).assertTrue();
});
done();
} catch (error) {
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_CALLBACK_001_02 fail, message = '
+ error);
done();
}
done();
});
})
\ 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('distributedPromise.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
......@@ -16,123 +16,76 @@
import mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility'
import fileio from '@ohos.fileio';
import {
describe,
it,
expect
} from 'deccjsunit/index';
import {describe, it, expect} from 'deccjsunit/index';
describe('fileAsset.callback.test.js', async function () {
describe('fileAssetUriTestCallback.test.js', async function() {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('MediaLibraryTest : getMediaLibrary OUT');
const fileKeyObj = mediaLibrary.FileKey;
function executeAtError(testNum, bool, error, done) {
console.info(
`SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} failed, error: ${error}`
);
expect(bool).assertTrue();
if (typeof done === "function") {
done();
}
}
//======================== FILE BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_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_CALLBACK_005_35', 0, async function (done) {
const testNum = "_005_35";
* @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.VIDEO;
let type = mediaLibrary.MediaType.IMAGE;
let fetchOp = {
uri: 'dataability://123456789/media/external/images/media/10',
networkId: '123456789',
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [type.toString()],
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()],
};
media.getFileAssets(fetchOp, (error, fetchFileResult) => {
try{
console.info(`MediaLibraryTest : ==1==`);
fetchFileResult.getAllObject((error, dataList) => {
console.info(`MediaLibraryTest : ==2==`);
try{
console.info(`MediaLibraryTest : ==3==`);
asset = dataList[0];
console.info(`MediaLibraryTest : ==4==`);
asset.open('r', (error, innerFd) => {
fd = innerFd;
try{
asset.close(fd, (error) => {
try{
asset.open('r', (error, innerFd1) => {
fd1 = innerFd1;
try{
asset.close(fd1, (error) => {
try{
if (fd > 0 && fd1 > 0) {
console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} success`);
expect(true).assertTrue();
done();
} else {
console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} failed`);
expect(false).assertTrue();
done();
}
}catch(error){
executeAtError(testNum, false, error, done);
}
});
}catch(error){
executeAtError(testNum, false, error, done);
}
});
}catch(error){
executeAtError(testNum, false, error, done);
}
});
}catch(error){
executeAtError(testNum, false, error, done);
}
});
}catch(error){
executeAtError(testNum, true, error, done);
}
});
}catch(error){
executeAtError(testNum, true, error, done);
}
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 : ==5==`);
console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} error:${error}`);
asset.close(fd, () =>{
try{
console.info(`MediaLibraryTest : ==6==`);
asset1.close(fd1, () => {
console.info(`MediaLibraryTest : ==7==`);
expect(false).assertTrue();
done();
});
}catch(error){
console.info(`MediaLibraryTest : ==8==`);
expect(false).assertTrue();
done();
}
});
console.info(
`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_URI_CALLBACK_005_35 error:${error}`);
expect(false).assertTrue();
done();
}
});
//======================== CLOSE BEGIN ================================
});
\ 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 fileio from '@ohos.fileio';
import {describe, it, expect} from 'deccjsunit/index';
describe('fileAssetUriTestPromise.test.js', async function() {
var context = featureAbility.getContext();
console.info('MediaLibraryTest : getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
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 ================================
});
\ No newline at end of file
......@@ -79,11 +79,7 @@ async function getFileAssetsBy(done, type) {
try {
let fetchFileResult = await media.getFileAssets(Op);
const fetchCount = fetchFileResult.getCount();
if(type == 'parent') {
expect(fetchCount == 0).assertTrue();
} else{
expect(fetchCount > 0).assertTrue();
}
expect(fetchCount > 0).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册