提交 8d51ce41 编写于 作者: P panqiangbiao

fix code issue

Signed-off-by: Npanqiangbiao <panqiangbiao@huawei.com>
上级 5ddc1a51
......@@ -24,8 +24,14 @@
"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",
......@@ -48,6 +54,22 @@
"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",
"chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"killall com.ohos.medialibrary.MediaScannerAbilityA",
......@@ -55,7 +77,7 @@
],
"teardown-command":[
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/database/*"
"rm -rf /data/accounts/account_0/appdata/com.ohos.medialibrary.MediaLibraryDataA/*"
]
},
{
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
require('./getPermission.test.js')
// phase I
require('./albumGetFileAssetsCallback.test.js')
require('./albumGetFileAssetsPromise.test.js')
require('./favoriteTestCallBack.test.js')
......
......@@ -14,17 +14,17 @@
*/
import mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
describe('albumGetFileAssetsCallback.test.js', async function() {
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() {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
const fileKeyObj = mediaLibrary.FileKey;
......@@ -32,7 +32,8 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
const count = 3;
const countOne = 1;
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_01
* @tc.name : getFileAssets
......@@ -41,12 +42,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_01', 0, async function(done) {
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',
selections: '',
selectionArgs: [],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(allTypefetchOp);
const album = albumList[0];
......@@ -55,7 +56,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -74,12 +75,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_02', 0, async function(done) {
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',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', imageType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAlbumfetchOp);
const album = albumList[0];
......@@ -88,7 +89,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -107,12 +108,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_03', 0, async function(done) {
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',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', audioType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(audioAlbumfetchOp);
const album = albumList[0];
......@@ -121,7 +122,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -139,12 +140,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_04', 0, async function(done) {
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',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', videoType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAlbumfetchOp);
const album = albumList[0];
......@@ -153,7 +154,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -171,12 +172,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_05', 0, async function(done) {
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',
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];
......@@ -185,7 +186,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -203,12 +204,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_06', 0, async function(done) {
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',
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];
......@@ -217,7 +218,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -235,12 +236,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_07', 0, async function(done) {
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',
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];
......@@ -249,7 +250,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -267,13 +268,13 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_08', 0, async function(done) {
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',
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];
......@@ -282,7 +283,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
}
});
......@@ -300,12 +301,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_09', 0, async function(done) {
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',
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
......@@ -314,7 +315,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
}
});
......@@ -332,12 +333,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_10', 0, async function(done) {
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',
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
......@@ -346,7 +347,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
}
});
......@@ -364,12 +365,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_11', 0, async function(done) {
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',
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
const albumList = await media.getAlbums(albumfetchOpOne);
const album = albumList[0];
......@@ -378,7 +379,7 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
expect(false).assertTrue();
done();
} else {
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
}
});
......@@ -396,12 +397,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_12', 0, async function(done) {
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',
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) {
......@@ -433,12 +434,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_13', 0, async function(done) {
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',
selections: fileKeyObj.MEDIA_TYPE + '= ? AND date_added < 0',
selectionArgs: [audioType.toString()],
order: 'date_added DESC LIMIT 0,1',
};
media.getAlbums(albumfetchOpNone, (error, albumList) => {
......@@ -470,12 +471,12 @@ describe('albumGetFileAssetsCallback.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_14', 0, async function(done) {
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',
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) {
......
......@@ -14,17 +14,17 @@
*/
import mediaLibrary from '@ohos.multimedia.medialibrary';
import featureAbility from '@ohos.ability.featureAbility';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
describe('albumGetFileAssetsPromise.test.js', async function() {
describe('albumGetFileAssetsPromise.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() {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
const fileKeyObj = mediaLibrary.FileKey;
......@@ -32,6 +32,7 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
const count = 3;
const countOne = 1;
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01
......@@ -41,17 +42,18 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01', 0, async function (done) {
try {
let allTypefetchOp = {
selections : '',
selectionArgs : [],
order : 'date_added DESC LIMIT 0,3',
selections: '',
selectionArgs: [],
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();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -67,17 +69,18 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02', 0, async function (done) {
try {
let imageAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ imageType.toString() ],
order : 'date_added DESC LIMIT 0,3',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', imageType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(imageAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(imageAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -93,17 +96,19 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03', 0, async function (done) {
try {
let audioAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ audioType.toString() ],
order : 'date_added DESC LIMIT 0,3',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', audioType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(audioAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(audioAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -119,17 +124,18 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04', 0, async function (done) {
try {
let videoAlbumfetchOp = {
selections : fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs : [ videoType.toString() ],
order : 'date_added DESC LIMIT 0,3',
selections: fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures', videoType.toString()],
order: 'date_added DESC LIMIT 0,3',
};
const albumList = await media.getAlbums(videoAlbumfetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(videoAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -145,17 +151,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_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',
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];
const fetchFileResult = await album.getFileAssets(imageAndVideoAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -171,17 +177,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_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',
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];
const fetchFileResult = await album.getFileAssets(imageAndAudioAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -197,17 +203,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_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',
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];
const fetchFileResult = await album.getFileAssets(videoAndAudioAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -223,18 +229,18 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_08', 0, async function(done) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_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',
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];
const fetchFileResult = await album.getFileAssets(imgAndVideoAndAudioAlbumfetchOp);
expect(fetchFileResult.getCount() <= count).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -250,17 +256,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_09', 0, async function(done) {
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',
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() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -276,17 +282,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_10', 0, async function(done) {
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',
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() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -302,17 +308,17 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_11', 0, async function(done) {
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',
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() <= count).assertTrue();
expect(fetchFileResult.getCount() == countOne).assertTrue();
done();
} catch (error) {
expect(false).assertTrue();
......@@ -328,16 +334,16 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12', 0, async function(done) {
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',
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);
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12 done');
done();
......@@ -356,16 +362,16 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13', 0, async function(done) {
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',
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);
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13 done');
done();
......@@ -384,16 +390,16 @@ describe('albumGetFileAssetsPromise.test.js', async function() {
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14', 0, async function(done) {
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',
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);
+ albumList.length);
expect(albumList.length == 0).assertTrue();
console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14 done');
done();
......
......@@ -28,35 +28,55 @@ let allTypefetchOp = {
};
let albumDeletefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/','DeleteAlbumCallback'],
selectionArgs: ['Pictures/', 'DeleteAlbumCallback'],
};
let albumCoverUrifetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/','weixin'],
selectionArgs: ['Pictures/', 'weixin'],
};
let imageAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
let allTypeInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo'],
};
let imageAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString()],
};
let videoAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
let videoAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', videoType.toString()],
};
let audioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
let audioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', audioType.toString()],
};
let imageAndVideoAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), videoType.toString()],
let imageAndVideoAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE +'= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString(), videoType.toString()],
};
let imageAndAudioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), audioType.toString()],
let imageAndAudioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString(), audioType.toString()],
};
let videoAndAudioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString(), audioType.toString()],
let videoAndAudioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', videoType.toString(), audioType.toString()],
};
function printAlbumMessage(testNum, album) {
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.albumId: ${album.albumId}`);
......@@ -67,16 +87,22 @@ function printAlbumMessage(testNum, album) {
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.relativePath: ${album.relativePath}`);
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.coverUri: ${album.coverUri}`);
}
const props = {
albumName: 'AblumInfo',
albumUri: 'dataability:///media/album/',
relativePath: 'Pictures/',
count: 1
}
function checkAlbumAttr(done, album) {
if (
album.albumId == undefined ||
album.albumName == undefined ||
album.albumUri == undefined ||
album.count == undefined ||
album.relativePath == undefined ||
album.albumName != props.albumName ||
album.albumUri != props.albumUri + album.albumId ||
album.count != props.count ||
album.relativePath != props.relativePath ||
album.coverUri == undefined
) {
console.info('ALBUM_CALLBACK getAlbum 001_01 failed');
expect(false).assertTrue();
done();
}
......@@ -94,7 +120,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01
* @tc.name : getAlbums
* @tc.desc : Get Album by AllTypefetchOp, print all album info,
* @tc.desc : Get Album by allTypeInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -102,7 +128,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01', 0, async function (done) {
try {
media.getAlbums(allTypefetchOp, (err, albumList) => {
media.getAlbums(allTypeInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -127,7 +153,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -135,7 +161,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02', 0, async function (done) {
try {
media.getAlbums(imageAlbumfetchOp, (err, albumList) => {
media.getAlbums(imageAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -160,7 +186,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03
* @tc.name : getAlbums
* @tc.desc : Get Album by videoAlbumfetchOp, print all album info,
* @tc.desc : Get Album by videoAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -168,7 +194,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03', 0, async function (done) {
try {
media.getAlbums(videoAlbumfetchOp, (err, albumList) => {
media.getAlbums(videoAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -193,7 +219,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04
* @tc.name : getAlbums
* @tc.desc : Get Album by audioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by audioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -201,7 +227,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04', 0, async function (done) {
try {
media.getAlbums(audioAlbumfetchOp, (err, albumList) => {
media.getAlbums(audioAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -225,7 +251,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAndVideoAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAndVideoAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -234,7 +260,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05', 0, async function (done) {
try {
media.getAlbums(imageAndVideoAlbumfetchOp, (err, albumList) => {
media.getAlbums(imageAndVideoAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -260,7 +286,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAndAudioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAndAudioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -269,7 +295,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06', 0, async function (done) {
try {
media.getAlbums(imageAndAudioAlbumfetchOp, (err, albumList) => {
media.getAlbums(imageAndAudioAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -294,7 +320,7 @@ describe('albumTestCallBack.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07
* @tc.name : getAlbums
* @tc.desc : Get Album by videoAndAudioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by videoAndAudioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -303,7 +329,7 @@ describe('albumTestCallBack.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07', 0, async function (done) {
try {
media.getAlbums(videoAndAudioAlbumfetchOp, (err, albumList) => {
media.getAlbums(videoAndAudioAlbumInfofetchOp, (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -582,18 +608,13 @@ describe('albumTestCallBack.test.js', async function () {
album.commitModify(async () => {
try {
const newAlbumList = await media.getAlbums(allTypefetchOp);
let passed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_CALLBACK Modify 003_01 passed');
expect(true).assertTrue();
done();
passed = true;
}
}
expect(passed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertTrue();
done();
} catch (error) {
console.info('ALBUM_CALLBACK Modify 003_01 commitModify failed, message = ' + error);
......@@ -626,18 +647,13 @@ describe('albumTestCallBack.test.js', async function () {
album.commitModify(async () => {
try {
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_CALLBACK Modify 003_02 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_CALLBACK Modify 003_02 commitModify failed, message = ' + error);
......@@ -674,18 +690,13 @@ describe('albumTestCallBack.test.js', async function () {
album.commitModify(async () => {
try {
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_CALLBACK Modify 003_03 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_CALLBACK Modify 003_03 commitModify failed, message = ' + error);
......@@ -719,18 +730,13 @@ describe('albumTestCallBack.test.js', async function () {
album.commitModify(async () => {
try {
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_CALLBACK Modify 003_04 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_CALLBACK Modify 003_04 commitModify failed, message = ' + error);
......@@ -762,18 +768,13 @@ describe('albumTestCallBack.test.js', async function () {
album.albumName = newName;
album.commitModify(async () => {
try {
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_CALLBACK Modify 003_05 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_CALLBACK Modify 003_05 commitModify failed, message = ' + error);
......@@ -803,7 +804,7 @@ describe('albumTestCallBack.test.js', async function () {
selectionArgs: [],
order: 'date_added DESC LIMIT 0,1',
};
media.getAlbums(albumCoverUrifetchOp, async(err, albumList) => {
media.getAlbums(albumCoverUrifetchOp, async (err, albumList) => {
if (albumList == undefined) {
expect(false).assertTrue();
done();
......@@ -821,7 +822,7 @@ describe('albumTestCallBack.test.js', async function () {
console.info('ALBUM_CALLBACK getAlbum 004_01 asset.uri = ' + asset.uri);
expect(asset.uri == album.coverUri).assertTrue();
done();
}
}
}
});
} catch (error) {
......@@ -842,7 +843,7 @@ describe('albumTestCallBack.test.js', async function () {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_005_01', 0, async function (done) {
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_005_01', 0, async function (done) {
try {
const albumList = await media.getAlbums(albumDeletefetchOp);
......
......@@ -28,36 +28,58 @@ let allTypefetchOp = {
};
let albumDeletefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/','DeleteAlbumPro'],
selectionArgs: ['Pictures/', 'DeleteAlbumPro'],
};
let albumCoverUrifetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/','weixin'],
selectionArgs: ['Pictures/', 'weixin'],
};
let imageAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
let allTypeInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo'],
};
let videoAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
let imageAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString()],
};
let audioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
let videoAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', videoType.toString()],
};
let imageAndVideoAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), videoType.toString()],
let audioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', 'AblumInfo', audioType.toString()],
};
let imageAndAudioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), audioType.toString()],
let imageAndVideoAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString(), videoType.toString()],
};
let imageAndAudioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', imageType.toString(), audioType.toString()],
};
let videoAndAudioAlbumfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString(), audioType.toString()],
let videoAndAudioAlbumInfofetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' +
fileKeyObj.ALBUM_NAME + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' +
fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/', 'AblumInfo', videoType.toString(), audioType.toString()],
};
function printAlbumMessage(testNum, album) {
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.albumId: ${album.albumId}`);
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.albumName: ${album.albumName}`);
......@@ -67,16 +89,22 @@ function printAlbumMessage(testNum, album) {
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.relativePath: ${album.relativePath}`);
console.info(`ALBUM_CALLBACK getAlbum ${testNum} album.coverUri: ${album.coverUri}`);
}
const props = {
albumName: 'AblumInfo',
albumUri: 'dataability:///media/album/',
relativePath: 'Pictures/',
count: 1
}
function checkAlbumAttr(done, album) {
if (
album.albumId == undefined ||
album.albumName == undefined ||
album.albumUri == undefined ||
album.count == undefined ||
album.relativePath == undefined ||
album.albumName != props.albumName ||
album.albumUri != props.albumUri + album.albumId ||
album.count != props.count ||
album.relativePath != props.relativePath ||
album.coverUri == undefined
) {
console.info('ALBUM_PROMISE getAlbum 001_01 failed');
expect(false).assertTrue();
done();
}
......@@ -85,16 +113,16 @@ function checkAlbumAttr(done, album) {
describe('albumTestPromise.test.js', async function () {
var context = featureAbility.getContext();
var media = mediaLibrary.getMediaLibrary(context);
beforeAll(function () {});
beforeEach(function () {});
afterEach(function () {});
afterAll(function () {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
// ------------------------------ 001 test start -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01
* @tc.name : getAlbums
* @tc.desc : Get Album by AllTypefetchOp, print all album info,
* @tc.desc : Get Album by allTypeInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -102,10 +130,10 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01', 0, async function (done) {
try {
const albumList = await media.getAlbums(allTypefetchOp);
const albumList = await media.getAlbums(allTypeInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_01', album);
checkAlbumAttr(done, album);
checkAlbumAttr(done, album, 3);
console.info('ALBUM_PROMISE getAlbum 001_01 success');
expect(true).assertTrue();
......@@ -120,7 +148,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -128,9 +156,10 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02', 0, async function (done) {
try {
const albumList = await media.getAlbums(imageAlbumfetchOp);
const albumList = await media.getAlbums(imageAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_02', album);
checkAlbumAttr(done, album);
console.info('ALBUM_PROMISE getAlbum 001_02 success');
......@@ -146,7 +175,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03
* @tc.name : getAlbums
* @tc.desc : Get Album by videoAlbumfetchOp, print all album info,
* @tc.desc : Get Album by videoAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -154,8 +183,9 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03', 0, async function (done) {
try {
const albumList = await media.getAlbums(videoAlbumfetchOp);
const albumList = await media.getAlbums(videoAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_03', album);
checkAlbumAttr(done, album);
......@@ -172,7 +202,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04
* @tc.name : getAlbums
* @tc.desc : Get Album by audioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by audioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName)
* @tc.size : MEDIUM
* @tc.type : Function
......@@ -180,8 +210,9 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04', 0, async function (done) {
try {
const albumList = await media.getAlbums(audioAlbumfetchOp);
const albumList = await media.getAlbums(audioAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_04', album);
checkAlbumAttr(done, album);
......@@ -198,7 +229,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAndVideoAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAndVideoAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -207,7 +238,7 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05', 0, async function (done) {
try {
const albumList = await media.getAlbums(imageAndVideoAlbumfetchOp);
const albumList = await media.getAlbums(imageAndVideoAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_05', album);
......@@ -226,7 +257,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06
* @tc.name : getAlbums
* @tc.desc : Get Album by imageAndAudioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by imageAndAudioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -235,8 +266,9 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06', 0, async function (done) {
try {
const albumList = await media.getAlbums(imageAndAudioAlbumfetchOp);
const albumList = await media.getAlbums(imageAndAudioAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_06', album);
checkAlbumAttr(done, album);
......@@ -253,7 +285,7 @@ describe('albumTestPromise.test.js', async function () {
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07
* @tc.name : getAlbums
* @tc.desc : Get Album by videoAndAudioAlbumfetchOp, print all album info,
* @tc.desc : Get Album by videoAndAudioAlbumInfofetchOp, print all album info,
* print all asset info, check asset info (mediaType, albumId, albumUri, albumName),
* check media types (imageType, audioType)
* @tc.size : MEDIUM
......@@ -262,8 +294,9 @@ describe('albumTestPromise.test.js', async function () {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07', 0, async function (done) {
try {
const albumList = await media.getAlbums(videoAndAudioAlbumfetchOp);
const albumList = await media.getAlbums(videoAndAudioAlbumInfofetchOp);
const album = albumList[0];
printAlbumMessage('001_07', album);
checkAlbumAttr(done, album);
......@@ -481,18 +514,14 @@ describe('albumTestPromise.test.js', async function () {
album.albumName = newName;
await album.commitModify();
const newAlbumList = await media.getAlbums(allTypefetchOp);
let passed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_PROMISE Modify 003_01 passed');
expect(true).assertTrue();
done();
passed = true;
}
}
expect(passed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertTrue();
done();
} catch (error) {
console.info('ALBUM_PROMISE Modify 003_01 failed, message = ' + error);
......@@ -520,18 +549,14 @@ describe('albumTestPromise.test.js', async function () {
album.albumName = newName;
await album.commitModify();
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_PROMISE Modify 003_02 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_PROMISE Modify 003_02 passed');
......@@ -562,18 +587,14 @@ describe('albumTestPromise.test.js', async function () {
album.albumName = newName;
await album.commitModify();
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_PROMISE Modify 003_04 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName == newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_PROMISE Modify 003_04 passed');
......@@ -601,18 +622,14 @@ describe('albumTestPromise.test.js', async function () {
album.albumName = newName;
await album.commitModify();
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_PROMISE Modify 003_05 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName === newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_PROMISE Modify 003_05 passed');
......@@ -640,18 +657,14 @@ describe('albumTestPromise.test.js', async function () {
album.albumName = newName;
await album.commitModify();
const newAlbumList = await media.getAlbums(allTypefetchOp);
let changed = false;
for (let i = 0; i < newAlbumList.length; i++) {
const album = newAlbumList[i];
if (album.albumId == albumId && album.albumName == newName) {
console.info('ALBUM_PROMISE Modify 003_06 failed');
expect(false).assertTrue();
done();
changed = true;
}
}
expect(!changed).assertTrue();
let currentfetchOp = {
selections: fileKeyObj.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
const newAlbumList = await media.getAlbums(currentfetchOp);
expect(newAlbumList[0].albumName === newName).assertFalse();
done();
} catch (error) {
console.info('ALBUM_PROMISE Modify 003_06 passed');
......
......@@ -64,10 +64,10 @@ describe('fileTestCallBack.test.js', function () {
console.info('getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('getMediaLibrary OUT');
beforeAll(function () {});
beforeEach(function () {});
afterEach(function () {});
afterAll(function () {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
async function copyFile(fd1, fd2) {
let stat = await fileio.fstat(fd1);
......@@ -97,7 +97,7 @@ describe('fileTestCallBack.test.js', function () {
`${new Date().getTime()}.jpg`,
path,
async (err, creatAsset1) => {
if(creatAsset1 == undefined) {
if (creatAsset1 == undefined) {
expect(false).assertTrue();
done();
} else {
......@@ -189,7 +189,7 @@ describe('fileTestCallBack.test.js', function () {
const newAssets = await media.getFileAssets(idOP);
const newdataList = await newAssets.getAllObject();
const newAsset = newdataList[0];
if (asset.dateModified != undefined) {
if (newAsset.dateModified != asset.dateModified) {
console.info('ASSET_CALLBACK getFileAssets 001_07 passed');
......@@ -277,7 +277,7 @@ describe('fileTestCallBack.test.js', function () {
`${new Date().getTime()}.mp4`,
path,
async (err, creatAsset1) => {
if(creatAsset1 == undefined) {
if (creatAsset1 == undefined) {
expect(false).assertTrue();
done();
} else {
......@@ -371,7 +371,7 @@ describe('fileTestCallBack.test.js', function () {
const newAssets = await media.getFileAssets(idOP);
const newdataList = await newAssets.getAllObject();
const newAsset = newdataList[0];
if (asset.dateModified != undefined) {
if (newAsset.dateModified != asset.dateModified) {
console.info('ASSET_CALLBACK getFileAssets 002_07 passed');
......@@ -392,7 +392,7 @@ describe('fileTestCallBack.test.js', function () {
done();
}
});
} catch (error) {
} catch (error) {
console.info('ASSET_CALLBACK getFileAssets 002_07 failed, message = ' + error);
}
});
......@@ -477,7 +477,7 @@ describe('fileTestCallBack.test.js', function () {
done();
}
);
} catch (error) {
console.info('ASSET_CALLBACK createAsset 003_01 failed');
expect(false).assertTrue();
......@@ -546,24 +546,12 @@ describe('fileTestCallBack.test.js', function () {
const newAssets = await media.getFileAssets(idOP);
const newdataList = await newAssets.getAllObject();
const newAsset = newdataList[0];
if (asset.dateModified != undefined) {
if (newAsset.dateModified != asset.dateModified) {
console.info('ASSET_CALLBACK getFileAssets 003_07 passed');
expect(true).assertTrue();
done();
} else {
console.info('ASSET_CALLBACK getFileAssets 003_07 failed');
expect(false).assertTrue();
done();
}
} else if (newAsset.dateModified != undefined) {
console.info('ASSET_CALLBACK getFileAssets 003_07 passed');
expect(true).assertTrue();
expect(newAsset.dateModified != asset.dateModified).assertTrue()
done();
} else {
console.info('ASSET_CALLBACK getFileAssets 003_07 failed');
expect(false).assertTrue();
expect(newAsset.dateModified != undefined).assertTrue();
done();
}
});
......@@ -694,13 +682,13 @@ describe('fileTestCallBack.test.js', function () {
const dataList = await fileAssets.getAllObject();
const asset = dataList[0];
asset.title = `title_${new Date().getTime()}`;
asset.commitModify(async ()=> {
asset.commitModify(async () => {
const id = asset.id;
const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] };
const newAssets = await media.getFileAssets(idOP);
const newdataList = await newAssets.getAllObject();
const newAsset = newdataList[0];
if (asset.dateModified != undefined) {
if (newAsset.dateModified != asset.dateModified) {
console.info('ASSET_CALLBACK getFileAssets 004_07 passed');
......
......@@ -64,10 +64,10 @@ describe('fileTestPromise.test.js', function () {
console.info('getMediaLibrary IN');
var media = mediaLibrary.getMediaLibrary(context);
console.info('getMediaLibrary OUT');
beforeAll(function () {});
beforeEach(function () {});
afterEach(function () {});
afterAll(function () {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
async function copyFile(fd1, fd2) {
let stat = await fileio.fstat(fd1);
......@@ -530,22 +530,10 @@ describe('fileTestPromise.test.js', function () {
const newAsset = newdataList[0];
if (asset.dateModified != undefined) {
if (newAsset.dateModified != asset.dateModified) {
console.info('ASSET_PROMISE getFileAssets 003_07 passed');
expect(true).assertTrue();
done();
} else {
console.info('ASSET_PROMISE getFileAssets 003_07 failed');
expect(false).assertTrue();
done();
}
} else if (newAsset.dateModified != undefined) {
console.info('ASSET_PROMISE getFileAssets 003_07 passed');
expect(true).assertTrue();
expect(newAsset.dateModified != asset.dateModified).assertTrue()
done();
} else {
console.info('ASSET_PROMISE getFileAssets 003_07 failed');
expect(false).assertTrue();
expect(newAsset.dateModified != undefined).assertTrue();
done();
}
} catch (error) {
......
......@@ -52,22 +52,44 @@ let filesfetchOp = {
selectionArgs: [fileType.toString()],
};
let imageRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString()],
};
let videoRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', videoType.toString()],
};
let audioRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', audioType.toString()],
};
let fileRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', fileType.toString()],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let imageAndVideofetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), videoType.toString()],
selections: fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString(), videoType.toString()],
};
let imageAndVideoAndfilefetchOp = {
selections:
fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ?',
selectionArgs: [imageType.toString(), videoType.toString(), fileType.toString()],
'= ?)',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString(), videoType.toString(), fileType.toString()],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let imageAndVideoAndfileAndAudiofetchOp = {
selections:
fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
......@@ -75,15 +97,18 @@ let imageAndVideoAndfileAndAudiofetchOp = {
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ?',
'= ?)',
selectionArgs: [
'Pictures/MediaLibraryTest/',
imageType.toString(),
videoType.toString(),
fileType.toString(),
audioType.toString(),
],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let allTypefetchOp = {
selections: '',
selectionArgs: [],
......@@ -96,6 +121,105 @@ async function copyFile(fd1, fd2) {
await fileio.write(fd2, buf);
}
const props = {
image: {
mimeType: 'image/*',
displayName: '01.jpg',
relativePath: 'Pictures/MediaLibraryTest/',
size: '348113',
mediaType: '3',
title: '01',
dateTaken: '0',
width: '1279',
height: '1706',
orientation: '0',
duration: '0',
albumId: '1118',
albumName: 'MediaLibraryTest'
},
video: {
mimeType: 'video/mp4',
displayName: '01.mp4',
relativePath: 'Pictures/MediaLibraryTest/',
size: '4853005',
mediaType: '4',
title: '01',
dateTaken: '0',
width: '1280',
height: '720',
orientation: '0',
duration: '10100',
albumName: 'MediaLibraryTest'
},
audio: {
mimeType: 'audio/mpeg',
displayName: '01.mp3',
relativePath: 'Pictures/MediaLibraryTest/',
size: '4113874',
mediaType: '5',
title: '01',
dateTaken: '0',
artist: 'Richard Stoltzman/Slovak Radio Symphony Orchestra',
width: '0',
height: '0',
orientation: '0',
duration: '169697',
albumName: 'MediaLibraryTest'
},
file: {
mimeType: 'file/*',
displayName: 'test.dat',
relativePath: 'Pictures/MediaLibraryTest/',
size: '10',
displayName: 'test.dat',
mediaType: '1',
title: 'test',
dateTaken: '0',
width: '0',
height: '0',
orientation: '0',
duration: '0',
albumName: 'MediaLibraryTest'
}
}
async function checkFileAssetAttr(done, fetchFileResult, type, count, typesArr) {
expect(fetchFileResult != undefined).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
let asset = await fetchFileResult.getFirstObject();
if (count > 1) {
type = asset.mimeType.match(/[a-z]+/g)[0]
}
if (type == 'audio' && asset.artist != props[type].artist) {
expect(false).assertTrue();
done();
}
if (typesArr) {
let assetList = await fetchFileResult.getAllObject();
for (const assetItem of assetList) {
expect(typesArr.includes(assetItem.mimeType)).assertTrue();
}
}
if (
asset.mimeType != props[type].mimeType ||
asset.displayName != props[type].displayName ||
asset.relativePath != props[type].relativePath ||
asset.size != props[type].size ||
asset.mediaType != props[type].mediaType ||
asset.title != props[type].title ||
asset.dateTaken != props[type].dateTaken ||
asset.width != props[type].width ||
asset.height != props[type].height ||
asset.orientation != props[type].orientation ||
asset.duration != props[type].duration ||
asset.albumName != props[type].albumName
) {
expect(false).assertTrue();
done();
}
}
describe('mediaLibraryTestCallBack.test.js', function () {
const context = featureAbility.getContext();
const media = mediaLibrary.getMediaLibrary(context);
......@@ -120,8 +244,10 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_001', 0, async function (done) {
try {
media.getFileAssets(imagesfetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(imageRelativefetchOp, async (err, fetchFileResult) => {
let count = 1;
let type = 'image';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
});
} catch (error) {
......@@ -141,8 +267,10 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_002', 0, async function (done) {
try {
media.getFileAssets(videosfetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(videoRelativefetchOp, async (err, fetchFileResult) => {
let count = 1;
let type = 'video';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
});
} catch (error) {
......@@ -162,8 +290,10 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_003', 0, async function (done) {
try {
media.getFileAssets(audiosfetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(audioRelativefetchOp, async (err, fetchFileResult) => {
let count = 1;
let type = 'audio';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
});
} catch (error) {
......@@ -183,8 +313,10 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_004', 0, async function (done) {
try {
media.getFileAssets(filesfetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(fileRelativefetchOp, async (err, fetchFileResult) => {
let count = 1;
let type = 'file';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
});
} catch (error) {
......@@ -204,8 +336,11 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_005', 0, async function (done) {
try {
media.getFileAssets(imageAndVideofetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(imageAndVideofetchOp, async (err, fetchFileResult) => {
let count = 2;
let type = 'video';
let typesArr = ['image/*', 'video/mp4']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
});
} catch (error) {
......@@ -225,8 +360,11 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_006', 0, async function (done) {
try {
media.getFileAssets(imageAndVideoAndfilefetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(imageAndVideoAndfilefetchOp, async (err, fetchFileResult) => {
let count = 3;
let type = 'file';
let typesArr = ['image/*', 'video/mp4', 'file/*']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
});
} catch (error) {
......@@ -246,8 +384,11 @@ describe('mediaLibraryTestCallBack.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_007', 0, async function (done) {
try {
media.getFileAssets(imageAndVideoAndfileAndAudiofetchOp, (err, fetchFileResult) => {
expect(fetchFileResult != undefined).assertTrue();
media.getFileAssets(imageAndVideoAndfileAndAudiofetchOp, async (err, fetchFileResult) => {
let count = 4;
let type = 'audio';
let typesArr = ['image/*', 'video/mp4', 'file/*', 'audio/mpeg']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
});
} catch (error) {
......
......@@ -52,22 +52,45 @@ let filesfetchOp = {
selectionArgs: [fileType.toString()],
};
let imageRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString()],
};
let videoRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', videoType.toString()],
};
let audioRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', audioType.toString()],
};
let fileRelativefetchOp = {
selections: fileKeyObj.RELATIVE_PATH + '= ? AND ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/MediaLibraryTest/', fileType.toString()],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let imageAndVideofetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString(), videoType.toString()],
selections: fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?)',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString(), videoType.toString()],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let imageAndVideoAndfilefetchOp = {
selections:
fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ?',
selectionArgs: [imageType.toString(), videoType.toString(), fileType.toString()],
'= ?)',
selectionArgs: ['Pictures/MediaLibraryTest/', imageType.toString(), videoType.toString(), fileType.toString()],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let imageAndVideoAndfileAndAudiofetchOp = {
selections:
fileKeyObj.RELATIVE_PATH + '= ? AND (' +
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
......@@ -75,13 +98,15 @@ let imageAndVideoAndfileAndAudiofetchOp = {
fileKeyObj.MEDIA_TYPE +
'= ? or ' +
fileKeyObj.MEDIA_TYPE +
'= ?',
'= ?)',
selectionArgs: [
'Pictures/MediaLibraryTest/',
imageType.toString(),
videoType.toString(),
fileType.toString(),
audioType.toString(),
],
order: fileKeyObj.DATE_ADDED + " DESC",
};
let allTypefetchOp = {
......@@ -96,14 +121,114 @@ async function copyFile(fd1, fd2) {
await fileio.write(fd2, buf);
}
const props = {
image: {
mimeType: 'image/*',
displayName: '01.jpg',
relativePath: 'Pictures/MediaLibraryTest/',
size: '348113',
mediaType: '3',
title: '01',
dateTaken: '0',
width: '1279',
height: '1706',
orientation: '0',
duration: '0',
albumId: '1118',
albumName: 'MediaLibraryTest'
},
video: {
mimeType: 'video/mp4',
displayName: '01.mp4',
relativePath: 'Pictures/MediaLibraryTest/',
size: '4853005',
mediaType: '4',
title: '01',
dateTaken: '0',
width: '1280',
height: '720',
orientation: '0',
duration: '10100',
albumName: 'MediaLibraryTest'
},
audio: {
mimeType: 'audio/mpeg',
displayName: '01.mp3',
relativePath: 'Pictures/MediaLibraryTest/',
size: '4113874',
mediaType: '5',
title: '01',
dateTaken: '0',
artist: 'Richard Stoltzman/Slovak Radio Symphony Orchestra',
width: '0',
height: '0',
orientation: '0',
duration: '169697',
albumName: 'MediaLibraryTest'
},
file: {
mimeType: 'file/*',
displayName: 'test.dat',
relativePath: 'Pictures/MediaLibraryTest/',
size: '10',
displayName: 'test.dat',
mediaType: '1',
title: 'test',
dateTaken: '0',
width: '0',
height: '0',
orientation: '0',
duration: '0',
albumName: 'MediaLibraryTest'
}
}
async function checkFileAssetAttr(done, fetchFileResult, type, count, typesArr) {
expect(fetchFileResult != undefined).assertTrue();
expect(fetchFileResult.getCount() == count).assertTrue();
let asset = await fetchFileResult.getFirstObject();
if (count > 1) {
type = asset.mimeType.match(/[a-z]+/g)[0]
}
if (type == 'audio' && asset.artist != props[type].artist) {
expect(false).assertTrue();
done();
}
if (typesArr) {
let assetList = await fetchFileResult.getAllObject();
for (const assetItem of assetList) {
expect(typesArr.includes(assetItem.mimeType)).assertTrue();
}
}
if (
asset.mimeType != props[type].mimeType ||
asset.displayName != props[type].displayName ||
asset.relativePath != props[type].relativePath ||
asset.size != props[type].size ||
asset.mediaType != props[type].mediaType ||
asset.title != props[type].title ||
asset.dateTaken != props[type].dateTaken ||
asset.width != props[type].width ||
asset.height != props[type].height ||
asset.orientation != props[type].orientation ||
asset.duration != props[type].duration ||
asset.albumName != props[type].albumName
) {
expect(false).assertTrue();
done();
}
}
describe('mediaLibraryTestPromise.test.js', function () {
const context = featureAbility.getContext();
const media = mediaLibrary.getMediaLibrary(context);
beforeAll(function () {});
beforeEach(function () {});
afterEach(function () {});
afterAll(function () {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
var timestamp = new Date().getTime();
var jpgName = timestamp + '.jpg';
......@@ -140,8 +265,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_001', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
expect(fetchFileResult != undefined).assertTrue();
const fetchFileResult = await media.getFileAssets(imageRelativefetchOp);
let count = 1;
let type = 'image';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 001 failed, error: ${error}`);
......@@ -160,8 +287,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_002', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(videosfetchOp);
expect(fetchFileResult != undefined).assertTrue();
const fetchFileResult = await media.getFileAssets(videoRelativefetchOp);
let count = 1;
let type = 'video';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 002 failed, error: ${error}`);
......@@ -180,8 +309,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_003', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(audiosfetchOp);
expect(fetchFileResult != undefined).assertTrue();
const fetchFileResult = await media.getFileAssets(audioRelativefetchOp);
let count = 1;
let type = 'audio';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 003 failed, error: ${error}`);
......@@ -200,8 +331,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_004', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(filesfetchOp);
expect(fetchFileResult != undefined).assertTrue();
const fetchFileResult = await media.getFileAssets(fileRelativefetchOp);
let count = 1;
let type = 'file';
await checkFileAssetAttr(done, fetchFileResult, type, count)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 004 failed, error: ${error}`);
......@@ -221,7 +354,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_005', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imageAndVideofetchOp);
expect(fetchFileResult != undefined).assertTrue();
let count = 2;
let type = 'video';
let typesArr = ['image/*', 'video/mp4']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 005 failed, error: ${error}`);
......@@ -241,7 +377,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_006', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imageAndVideoAndfilefetchOp);
expect(fetchFileResult != undefined).assertTrue();
let count = 3;
let type = 'file';
let typesArr = ['image/*', 'video/mp4', 'file/*']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 006 failed, error: ${error}`);
......@@ -261,7 +400,10 @@ describe('mediaLibraryTestPromise.test.js', function () {
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_007', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imageAndVideoAndfileAndAudiofetchOp);
expect(fetchFileResult != undefined).assertTrue();
let count = 4;
let type = 'audio';
let typesArr = ['image/*', 'video/mp4', 'file/*', 'audio/mpeg']
await checkFileAssetAttr(done, fetchFileResult, type, count, typesArr)
done();
} catch (error) {
console.info(`MediaLibraryTest : getFileAssets 007 failed, error: ${error}`);
......@@ -829,18 +971,18 @@ describe('mediaLibraryTestPromise.test.js', function () {
}
});
/**
* @tc.number : SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_001
* @tc.name : createAsset
* @tc.desc : Create File Asset image (does not exist)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_009', 0, async function (done) {
/**
* @tc.number : SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_001
* @tc.name : createAsset
* @tc.desc : Create File Asset image (does not exist)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_009', 0, async function (done) {
try {
const path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE);
const filePath = path + "image/";
const filePath = path + "image/";
const fileAssets = await media.getFileAssets(videosfetchOp);
const dataList = await fileAssets.getAllObject();
const asset1 = dataList[0];
......
......@@ -20,10 +20,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const context = featureAbility.getContext();
const media = mediaLibrary.getMediaLibrary(context);
beforeAll(function() {});
beforeEach(function() {});
afterEach(function() {});
afterAll(function() {});
beforeAll(function () { });
beforeEach(function () { });
afterEach(function () { });
afterAll(function () { });
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let videoType = mediaLibrary.MediaType.VIDEO;
......@@ -67,11 +67,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut > 0).assertTrue();
media.off('imageChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut > 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 001 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -99,11 +101,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut > 0).assertTrue();
media.off('videoChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut > 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 002 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -131,11 +135,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut > 0).assertTrue();
media.off('audioChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut > 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 003 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -163,11 +169,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut > 0).assertTrue();
media.off('fileChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut > 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 004 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -195,11 +203,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut == 0).assertTrue();
media.off('albumChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut == 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 005 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -229,11 +239,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut == 0).assertTrue();
media.off('deviceChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut == 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -263,11 +275,13 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
await asset.commitModify();
setTimeout(() => {
expect(conut == 0).assertTrue();
media.off('remoteFileChange');
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
expect(conut == 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -292,17 +306,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('imageChange');
done();
});
media.off('imageChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
media.off('imageChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 001 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 001 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 001 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -327,17 +353,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('videoChange');
done();
});
media.off('videoChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
media.off('videoChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 002 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 002 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 002 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -362,17 +400,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('audioChange');
done();
});
media.off('audioChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(audiosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
media.off('audioChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 003 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 003 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 003 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -397,17 +447,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('fileChange');
done();
});
media.off('fileChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
media.off('fileChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 004 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 004 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 004 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -432,17 +494,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('albumChange');
done();
});
media.off('albumChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'albumChange';
media.off('albumChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 005 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 005 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 005 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -467,17 +541,29 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('deviceChange');
done();
});
media.off('deviceChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'deviceChange';
media.off('deviceChange');
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 006 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 006 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 006 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -502,17 +588,30 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media.off('remoteFileChange');
done();
});
await new Promise(res => {
setTimeout(() => {
res()
}, 300)
})
media.off('remoteFileChange');
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'remoteFileChange';
await new Promise(res => {
setTimeout(() => {
res()
}, 600)
})
await asset.commitModify();
setTimeout(() => {
console.info('MediaLibraryTest : off 007 passed');
expect(true).assertTrue();
done();
}, 1000);
await new Promise(res => {
setTimeout(() => {
res()
}, 1000)
})
console.info('MediaLibraryTest : off 007 passed');
expect(true).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 006 failed, error: ${error}`);
expect(false).assertTrue();
......@@ -541,4 +640,5 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
done();
}
});
});
\ No newline at end of file
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册