未验证 提交 7056046d 编写于 作者: O openharmony_ci 提交者: Gitee

!5993 【3.1-Release】【xts】fix asset[]

Merge pull request !5993 from yangbo/3.1-release_1020
...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility'; 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';
function printAttr(asset) {
for (const key in asset) {
console.info(`${key}: asset[key]`);
}
}
function checkAttrs(done, asset, tNum) {
let passed = true;
for (const key in asset) {
if (asset[key] == undefined) {
passed = false;
break;
}
}
if (passed) {
console.info(`FileAsset checkAttrs ${tNum} passed`);
expect(true).assertTrue();
done();
} else {
console.info(`FileAsset checkAttrs ${tNum} failed`);
expect(false).assertTrue();
done();
}
}
function sleep(time){ function sleep(time){
for (let t = Date.now(); Date.now() - t <= time;); for (let t = Date.now(); Date.now() - t <= time;);
} }
...@@ -323,8 +301,8 @@ describe('fileAsset2.test.js', async function () { ...@@ -323,8 +301,8 @@ describe('fileAsset2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(imagesfetchOp); const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '001'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 001 failed, message = ' + error); console.info('FileAsset checkAttr 001 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -345,8 +323,8 @@ describe('fileAsset2.test.js', async function () { ...@@ -345,8 +323,8 @@ describe('fileAsset2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(videosfetchOp); const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '002'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 002 failed, message = ' + error); console.info('FileAsset checkAttr 002 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -367,8 +345,8 @@ describe('fileAsset2.test.js', async function () { ...@@ -367,8 +345,8 @@ describe('fileAsset2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(audiosfetchOp); const fetchFileResult = await media.getFileAssets(audiosfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '003'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error); console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -390,8 +368,8 @@ describe('fileAsset2.test.js', async function () { ...@@ -390,8 +368,8 @@ describe('fileAsset2.test.js', async function () {
const album = albumList[0]; const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp); const fetchFileResult = await album.getFileAssets(allTypefetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '004'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error); console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility'; 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';
function printAttr(asset) {
for (const key in asset) {
console.info(`${key}: asset[key]`);
}
}
function checkAttrs(done, asset, tNum) {
let passed = true;
for (const key in asset) {
if (asset[key] == undefined) {
passed = false;
break;
}
}
if (passed) {
console.info(`FileAsset checkAttrs ${tNum} passed`);
expect(true).assertTrue();
done();
} else {
console.info(`FileAsset checkAttrs ${tNum} failed`);
expect(false).assertTrue();
done();
}
}
function sleep(time){ function sleep(time){
for (let t = Date.now(); Date.now() - t <= time;); for (let t = Date.now(); Date.now() - t <= time;);
} }
...@@ -347,8 +325,8 @@ describe('fileAssetCallBack2.test.js', async function () { ...@@ -347,8 +325,8 @@ describe('fileAssetCallBack2.test.js', async function () {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '001'); done();
} }
}); });
} catch (error) { } catch (error) {
...@@ -374,8 +352,8 @@ describe('fileAssetCallBack2.test.js', async function () { ...@@ -374,8 +352,8 @@ describe('fileAssetCallBack2.test.js', async function () {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '002'); done();
} }
}); });
} catch (error) { } catch (error) {
...@@ -401,8 +379,8 @@ describe('fileAssetCallBack2.test.js', async function () { ...@@ -401,8 +379,8 @@ describe('fileAssetCallBack2.test.js', async function () {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '003'); done();
} }
}); });
} catch (error) { } catch (error) {
...@@ -430,8 +408,8 @@ describe('fileAssetCallBack2.test.js', async function () { ...@@ -430,8 +408,8 @@ describe('fileAssetCallBack2.test.js', async function () {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '004'); done();
} }
}); });
......
...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -17,29 +17,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility'; 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';
function printAttr(asset) {
for (const key in asset) {
console.info(`${key}: asset[key]`);
}
}
function checkAttrs(done, asset, tNum) {
let passed = true;
for (const key in asset) {
if (asset[key] == undefined) {
passed = false;
break;
}
}
if (passed) {
console.info(`FileAsset checkAttrs ${tNum} passed`);
expect(true).assertTrue();
done();
} else {
console.info(`FileAsset checkAttrs ${tNum} failed`);
expect(false).assertTrue();
done();
}
}
function sleep(time){ function sleep(time){
for (let t = Date.now(); Date.now() - t <= time;); for (let t = Date.now(); Date.now() - t <= time;);
} }
...@@ -323,8 +301,8 @@ describe('fileAssetPromise2.test.js', async function () { ...@@ -323,8 +301,8 @@ describe('fileAssetPromise2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(imagesfetchOp); const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '001'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 001 failed, message = ' + error); console.info('FileAsset checkAttr 001 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -345,8 +323,8 @@ describe('fileAssetPromise2.test.js', async function () { ...@@ -345,8 +323,8 @@ describe('fileAssetPromise2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(videosfetchOp); const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '002'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 002 failed, message = ' + error); console.info('FileAsset checkAttr 002 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -367,8 +345,8 @@ describe('fileAssetPromise2.test.js', async function () { ...@@ -367,8 +345,8 @@ describe('fileAssetPromise2.test.js', async function () {
const fetchFileResult = await media.getFileAssets(audiosfetchOp); const fetchFileResult = await media.getFileAssets(audiosfetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '003'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error); console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -390,8 +368,8 @@ describe('fileAssetPromise2.test.js', async function () { ...@@ -390,8 +368,8 @@ describe('fileAssetPromise2.test.js', async function () {
const album = albumList[0]; const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp); const fetchFileResult = await album.getFileAssets(allTypefetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
printAttr(asset); expect(true).assertTrue();
checkAttrs(done, asset, '004'); done();
} catch (error) { } catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error); console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -41,18 +41,6 @@ let filesfetchOp = { ...@@ -41,18 +41,6 @@ let filesfetchOp = {
selectionArgs: [fileType.toString(), 'Documents/'], selectionArgs: [fileType.toString(), 'Documents/'],
}; };
function checkAssetAttr(done, attr, testNum, asset, checkType) {
if (checkType && asset[attr] != checkType) {
console.info(`ASSET_CALLBACK getFileAssets ${testNum} failed`);
expect(false).assertTrue();
done();
} else if (asset[attr] == undefined) {
console.info(`ASSET_CALLBACK getFileAssets ${testNum} failed`);
expect(false).assertTrue();
done();
}
}
let path; let path;
let presetAsset; let presetAsset;
let displayName; let displayName;
......
...@@ -41,18 +41,6 @@ let filesfetchOp = { ...@@ -41,18 +41,6 @@ let filesfetchOp = {
selectionArgs: [fileType.toString(), 'Documents/'], selectionArgs: [fileType.toString(), 'Documents/'],
}; };
function checkAssetAttr(done, attr, testNum, asset, checkType) {
if (checkType && asset[attr] != checkType) {
console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`);
expect(false).assertTrue();
done();
} else if (asset[attr] == undefined) {
console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`);
expect(false).assertTrue();
done();
}
}
let path; let path;
let presetAsset; let presetAsset;
let displayName; let displayName;
......
...@@ -64,18 +64,7 @@ const filekeys = { ...@@ -64,18 +64,7 @@ const filekeys = {
dateTaken: 'DATE_TAKEN', dateTaken: 'DATE_TAKEN',
} }
async function getFileAssetsBy(done, type) { async function getFileAssetsBy(done, Op, type) {
let assetOp = imagesfetchOp
if(type == 'audioAlbum' || type == 'artist' || type == 'duration') {
assetOp = audiosfetchOp
}
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey[filekeys[type]] + '= ?',
selectionArgs: [asset[type] + ''],
};
try { try {
media.getFileAssets(Op, async(err, fetchFileResult) => { media.getFileAssets(Op, async(err, fetchFileResult) => {
if (fetchFileResult == undefined) { if (fetchFileResult == undefined) {
...@@ -116,7 +105,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -116,7 +105,14 @@ describe('filekeyTestPromise.test.js', async function () {
*/ */
it('test_fileKey_001', 0, async function (done) { it('test_fileKey_001', 0, async function (done) {
getFileAssetsBy(done, 'parent'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.PARENT + '= ?',
selectionArgs: [asset.parent + ''],
};
getFileAssetsBy(done, Op, 'parent');
}); });
/** /**
...@@ -128,7 +124,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -128,7 +124,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_002', 0, async function (done) { it('test_fileKey_002', 0, async function (done) {
getFileAssetsBy(done, 'mimeType'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.MIME_TYPE + '= ?',
selectionArgs: [asset.mimeType + ''],
};
getFileAssetsBy(done, Op, 'mimeType');
}); });
/** /**
...@@ -140,7 +143,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -140,7 +143,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_003', 0, async function (done) { it('test_fileKey_003', 0, async function (done) {
getFileAssetsBy(done, 'size'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.SIZE + '= ?',
selectionArgs: [asset.size + ''],
};
getFileAssetsBy(done, Op, 'size');
}); });
/** /**
...@@ -152,8 +162,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -152,8 +162,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_004', 0, async function (done) { it('test_fileKey_004', 0, async function (done) {
let assetOp = imagesfetchOp
getFileAssetsBy(done, 'dateAdded'); const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_ADDED + '= ?',
selectionArgs: [asset.dateAdded + ''],
};
getFileAssetsBy(done, Op, 'dateAdded');
}); });
/** /**
...@@ -165,7 +181,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -165,7 +181,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_005', 0, async function (done) { it('test_fileKey_005', 0, async function (done) {
getFileAssetsBy(done, 'dateModified'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_MODIFIED + '= ?',
selectionArgs: [asset.dateModified + ''],
};
getFileAssetsBy(done, Op, 'dateModified');
}); });
/** /**
...@@ -177,7 +200,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -177,7 +200,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_006', 0, async function (done) { it('test_fileKey_006', 0, async function (done) {
getFileAssetsBy(done, 'dateTaken'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_TAKEN + '= ?',
selectionArgs: [asset.dateTaken + ''],
};
getFileAssetsBy(done, Op, 'dateTaken');
}); });
/** /**
...@@ -189,7 +219,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -189,7 +219,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_007', 0, async function (done) { it('test_fileKey_007', 0, async function (done) {
getFileAssetsBy(done, 'title'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.TITLE + '= ?',
selectionArgs: [asset.title + ''],
};
getFileAssetsBy(done, Op, 'title');
}); });
/** /**
...@@ -201,7 +238,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -201,7 +238,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_008', 0, async function (done) { it('test_fileKey_008', 0, async function (done) {
getFileAssetsBy(done, 'duration'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DURATION + '= ?',
selectionArgs: [asset.duration + ''],
};
getFileAssetsBy(done, Op, 'duration');
}); });
/** /**
...@@ -213,7 +257,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -213,7 +257,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_009', 0, async function (done) { it('test_fileKey_009', 0, async function (done) {
getFileAssetsBy(done, 'width'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.WIDTH + '= ?',
selectionArgs: [asset.width + ''],
};
getFileAssetsBy(done, Op, 'width');
}); });
/** /**
...@@ -225,7 +276,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -225,7 +276,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_010', 0, async function (done) { it('test_fileKey_010', 0, async function (done) {
getFileAssetsBy(done, 'height'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.HEIGHT + '= ?',
selectionArgs: [asset.height + ''],
};
getFileAssetsBy(done, Op, 'height');
}); });
/** /**
...@@ -237,7 +295,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -237,7 +295,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_011', 0, async function (done) { it('test_fileKey_011', 0, async function (done) {
getFileAssetsBy(done, 'orientation'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ORIENTATION + '= ?',
selectionArgs: [asset.orientation + ''],
};
getFileAssetsBy(done, Op, 'orientation');
}); });
/** /**
...@@ -249,7 +314,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -249,7 +314,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_012', 0, async function (done) { it('test_fileKey_012', 0, async function (done) {
getFileAssetsBy(done, 'albumId'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ALBUM_ID + '= ?',
selectionArgs: [asset.albumId + ''],
};
getFileAssetsBy(done, Op, 'albumId');
}); });
/** /**
...@@ -261,7 +333,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -261,7 +333,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0013', 0, async function (done) { it('test_fileKey_0013', 0, async function (done) {
getFileAssetsBy(done, 'albumName'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs: [asset.albumName + ''],
};
getFileAssetsBy(done, Op, 'albumName');
}); });
/** /**
...@@ -273,7 +352,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -273,7 +352,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0014', 0, async function (done) { it('test_fileKey_0014', 0, async function (done) {
getFileAssetsBy(done, 'artist'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ARTIST + '= ?',
selectionArgs: [asset.artist + ''],
};
getFileAssetsBy(done, Op, 'artist');
}); });
/** /**
...@@ -285,6 +371,13 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -285,6 +371,13 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0015', 0, async function (done) { it('test_fileKey_0015', 0, async function (done) {
getFileAssetsBy(done, 'audioAlbum'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.AUDIOALBUM + '= ?',
selectionArgs: [asset.audioAlbum + ''],
};
getFileAssetsBy(done, Op, 'audioAlbum');
}); });
}); });
...@@ -64,17 +64,8 @@ const filekeys = { ...@@ -64,17 +64,8 @@ const filekeys = {
dateTaken: 'DATE_TAKEN', dateTaken: 'DATE_TAKEN',
} }
async function getFileAssetsBy(done, type) { async function getFileAssetsBy(done, Op, type) {
let assetOp = imagesfetchOp
if(type == 'audioAlbum' || type == 'artist' || type == 'duration') {
assetOp = audiosfetchOp
}
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey[filekeys[type]] + '= ?',
selectionArgs: [asset[type] + ''],
};
try { try {
let fetchFileResult = await media.getFileAssets(Op); let fetchFileResult = await media.getFileAssets(Op);
...@@ -105,7 +96,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -105,7 +96,14 @@ describe('filekeyTestPromise.test.js', async function () {
*/ */
it('test_fileKey_001', 0, async function (done) { it('test_fileKey_001', 0, async function (done) {
getFileAssetsBy(done, 'parent'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.PARENT + '= ?',
selectionArgs: [asset.parent + ''],
};
getFileAssetsBy(done, Op, 'parent');
}); });
/** /**
...@@ -117,7 +115,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -117,7 +115,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_002', 0, async function (done) { it('test_fileKey_002', 0, async function (done) {
getFileAssetsBy(done, 'mimeType'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.MIME_TYPE + '= ?',
selectionArgs: [asset.mimeType + ''],
};
getFileAssetsBy(done, Op, 'mimeType');
}); });
/** /**
...@@ -129,7 +134,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -129,7 +134,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_003', 0, async function (done) { it('test_fileKey_003', 0, async function (done) {
getFileAssetsBy(done, 'size'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.SIZE + '= ?',
selectionArgs: [asset.size + ''],
};
getFileAssetsBy(done, Op, 'size');
}); });
/** /**
...@@ -141,8 +153,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -141,8 +153,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_004', 0, async function (done) { it('test_fileKey_004', 0, async function (done) {
let assetOp = imagesfetchOp
getFileAssetsBy(done, 'dateAdded'); const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_ADDED + '= ?',
selectionArgs: [asset.dateAdded + ''],
};
getFileAssetsBy(done, Op, 'dateAdded');
}); });
/** /**
...@@ -154,7 +172,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -154,7 +172,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_005', 0, async function (done) { it('test_fileKey_005', 0, async function (done) {
getFileAssetsBy(done, 'dateModified'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_MODIFIED + '= ?',
selectionArgs: [asset.dateModified + ''],
};
getFileAssetsBy(done, Op, 'dateModified');
}); });
/** /**
...@@ -166,7 +191,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -166,7 +191,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_006', 0, async function (done) { it('test_fileKey_006', 0, async function (done) {
getFileAssetsBy(done, 'dateTaken'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DATE_TAKEN + '= ?',
selectionArgs: [asset.dateTaken + ''],
};
getFileAssetsBy(done, Op, 'dateTaken');
}); });
/** /**
...@@ -178,7 +210,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -178,7 +210,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_007', 0, async function (done) { it('test_fileKey_007', 0, async function (done) {
getFileAssetsBy(done, 'title'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.TITLE + '= ?',
selectionArgs: [asset.title + ''],
};
getFileAssetsBy(done, Op, 'title');
}); });
/** /**
...@@ -190,7 +229,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -190,7 +229,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_008', 0, async function (done) { it('test_fileKey_008', 0, async function (done) {
getFileAssetsBy(done, 'duration'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.DURATION + '= ?',
selectionArgs: [asset.duration + ''],
};
getFileAssetsBy(done, Op, 'duration');
}); });
/** /**
...@@ -202,7 +248,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -202,7 +248,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_009', 0, async function (done) { it('test_fileKey_009', 0, async function (done) {
getFileAssetsBy(done, 'width'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.WIDTH + '= ?',
selectionArgs: [asset.width + ''],
};
getFileAssetsBy(done, Op, 'width');
}); });
/** /**
...@@ -214,7 +267,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -214,7 +267,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_010', 0, async function (done) { it('test_fileKey_010', 0, async function (done) {
getFileAssetsBy(done, 'height'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.HEIGHT + '= ?',
selectionArgs: [asset.height + ''],
};
getFileAssetsBy(done, Op, 'height');
}); });
/** /**
...@@ -226,7 +286,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -226,7 +286,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_011', 0, async function (done) { it('test_fileKey_011', 0, async function (done) {
getFileAssetsBy(done, 'orientation'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ORIENTATION + '= ?',
selectionArgs: [asset.orientation + ''],
};
getFileAssetsBy(done, Op, 'orientation');
}); });
/** /**
...@@ -238,7 +305,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -238,7 +305,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_012', 0, async function (done) { it('test_fileKey_012', 0, async function (done) {
getFileAssetsBy(done, 'albumId'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ALBUM_ID + '= ?',
selectionArgs: [asset.albumId + ''],
};
getFileAssetsBy(done, Op, 'albumId');
}); });
/** /**
...@@ -250,7 +324,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -250,7 +324,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0013', 0, async function (done) { it('test_fileKey_0013', 0, async function (done) {
getFileAssetsBy(done, 'albumName'); let assetOp = imagesfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs: [asset.albumName + ''],
};
getFileAssetsBy(done, Op, 'albumName');
}); });
/** /**
...@@ -262,7 +343,14 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -262,7 +343,14 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0014', 0, async function (done) { it('test_fileKey_0014', 0, async function (done) {
getFileAssetsBy(done, 'artist'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.ARTIST + '= ?',
selectionArgs: [asset.artist + ''],
};
getFileAssetsBy(done, Op, 'artist');
}); });
/** /**
...@@ -274,6 +362,13 @@ describe('filekeyTestPromise.test.js', async function () { ...@@ -274,6 +362,13 @@ describe('filekeyTestPromise.test.js', async function () {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('test_fileKey_0015', 0, async function (done) { it('test_fileKey_0015', 0, async function (done) {
getFileAssetsBy(done, 'audioAlbum'); let assetOp = audiosfetchOp
const fetchFileResult = await media.getFileAssets(assetOp);
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: mediaLibrary.FileKey.AUDIOALBUM + '= ?',
selectionArgs: [asset.audioAlbum + ''],
};
getFileAssetsBy(done, Op, 'audioAlbum');
}); });
}); });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册