提交 1c99fb40 编写于 作者: 梁家熙

add close for each fetchfileresult

Signed-off-by: N梁家熙 <liangjiaxi2@huawei.com>
Change-Id: I7bd8497b37498adccdf6f3fd6601a171566575d2
上级 1be5e6f4
......@@ -189,8 +189,10 @@ const checkPresetsAssets = async function (media, hapName) {
console.info(`${hapName} checkPresetsAssets failed;
assetsCount : presetsassetsCount = ${assetsCount} : ${presetsassetsCount}
albumsCount : presetsalbumsCount = ${albumsCount} : ${presetsalbumsCount}`);
fetchFileResult.close();
} else {
console.info(`${hapName} checkPresetsAssets passed`);
fetchFileResult.close();
}
};
......
......@@ -76,6 +76,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
getCount: ${fetchFileResult.getCount()}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
});
await sleep(500)
}
......@@ -107,6 +108,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
}
console.info(`${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
done();
});
......@@ -133,6 +135,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -74,6 +74,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
getCount: ${fetchFileResult.getCount()}`);
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
}
expect(count).assertEqual(expectAlbumCount);
done();
......@@ -103,6 +104,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
`${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}`
);
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`);
......@@ -133,6 +135,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`);
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`);
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
......
......@@ -519,6 +519,9 @@ export default function albumTestPromiseTest(abilityContext) {
let expectAlbumCount = 1;
let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOp);
for (const album of albumList) {
console.info(`URI: ${album.coverUri} + ${album.albumUri}`);
}
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
const album = albumList[0];
......@@ -526,12 +529,14 @@ export default function albumTestPromiseTest(abilityContext) {
const asset = await fetchFileResult.getFirstObject();
if (asset == undefined) {
console.info(`${testNum} failed asset undefined`);
fetchFileResult.close();
expect(false).assertTrue();
done();
return;
}
console.info(`Fetch URI: ${asset.uri}`);
expect(asset.uri).assertEqual(album.coverUri);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......
......@@ -188,6 +188,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -205,6 +206,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
}
if (!isNum(asset.dateTaken)) {
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......@@ -220,6 +222,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
}
expect(asset.orientation).assertEqual(props[type].orientation);
expect(asset.duration.toString()).assertEqual(props[type].duration);
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -250,14 +253,18 @@ export default function mediaLibraryTestCallback(abilityContext) {
const getFileAssetsAbnormal = async (done, testNum, fetchOps) => {
try {
media.getFileAssets(fetchOps, async (err) => {
media.getFileAssets(fetchOps, async (err, fetchFileResult) => {
if (err) {
console.info(`${testNum} err : ${err}`);
expect(true).assertTrue();
if (fetchFileResult != null) {
fetchFileResult.close();
}
done();
return;
}
expect(false).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -272,11 +279,13 @@ export default function mediaLibraryTestCallback(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 0);
expect(checkAssetCountPass).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -296,6 +305,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -305,6 +315,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
await creatAsset.close(creatAssetFd);
await asset.close(fd);
expect(true).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -330,15 +341,18 @@ export default function mediaLibraryTestCallback(abilityContext) {
media.createAsset(type, name, path, async (err, creatAsset) => {
if (err != undefined) {
expect(true).assertTrue();
fetchFileResult.close();
done();
return;
}
expect(false).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
}
} catch (error) {
......
......@@ -196,12 +196,14 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
}
if (!isNum(asset.dateTaken)) {
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
if (asset.size !== props[type].size) {
console.info(`${testNum}:: asset.size: props.size - ${asset.size} : ${props[type].size}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......@@ -216,6 +218,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
}
expect(asset.orientation).assertEqual(props[type].orientation);
expect(asset.duration.toString()).assertEqual(props[type].duration);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -238,8 +241,9 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
const getFileAssetsAbnormal = async (done, testNum, fetchOps) => {
try {
await media.getFileAssets(fetchOps);
let fetchFileResult = await media.getFileAssets(fetchOps);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -252,7 +256,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
let fetchFileResult = await media.getFileAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 0);
expect(checkAssetCountPass).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -274,6 +278,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
await creatAsset.close(creatAssetFd);
await asset.close(fd);
expect(true).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -297,9 +302,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
try {
await media.createAsset(type, name, path);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
expect(true).assertTrue();
fetchFileResult.close();
done();
}
} catch (error) {
......
......@@ -59,6 +59,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
await asset.commitModify();
await sleep(1000);
expect(count > 0).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -81,6 +82,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
await asset.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -212,6 +214,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
}, 1000);
});
expect(count == 0).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
......@@ -251,6 +254,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
}, 1000);
});
expect(count == 0).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 007 failed, error: ${error}`);
......@@ -397,6 +401,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
});
console.info("MediaLibraryTest : off 006 passed");
expect(true).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 006 failed, error: ${error}`);
......@@ -447,6 +452,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
});
console.info("MediaLibraryTest : off 007 passed");
expect(true).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`MediaLibraryTest : off 007 failed, error: ${error}`);
......
......@@ -55,12 +55,12 @@ export default function favoriteTestCallbackTest(abilityContext) {
asset.isFavorite(async (err, isFavorite) => {
if (err) {
expect(false).assertTrue();
await fetchFileResult.close();
fetchFileResult.close();
done();
return;
}
expect(isFavorite).assertEqual(false);
await fetchFileResult.close();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -79,12 +79,13 @@ export default function favoriteTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} failed err: ${err}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
let isFavorite = await asset.isFavorite();
expect(isFavorite).assertEqual(true);
await fetchFileResult.close();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -104,12 +105,13 @@ export default function favoriteTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} failed err: ${err}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
let isFavorite = await asset.isFavorite();
expect(isFavorite).assertEqual(false);
await fetchFileResult.close();
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -50,7 +50,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
let asset = await fetchFileResult.getFirstObject();
let isFavorite = await asset.isFavorite();
expect(isFavorite).assertEqual(false);
await fetchFileResult.close();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -67,7 +67,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
await asset.favorite(true);
let isFavorite = await asset.isFavorite();
expect(isFavorite).assertEqual(true);
await fetchFileResult.close();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -85,7 +85,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
await asset.favorite(false);
let isFavorite = await asset.isFavorite();
expect(isFavorite).assertEqual(false);
await fetchFileResult.close();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......
......@@ -69,6 +69,7 @@ export default function fileTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -85,6 +86,7 @@ export default function fileTestCallbackTest(abilityContext) {
await asset.close(fd);
console.info(`${testNum} displayName1: ${displayName1}, displayName2 :${displayName2} `);
expect(creatAsset1.id != creatAsset2.id).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -106,6 +108,7 @@ export default function fileTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -118,6 +121,7 @@ export default function fileTestCallbackTest(abilityContext) {
val = displayName;
}
expect(creatAsset[key]).assertEqual(val);
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -138,15 +142,18 @@ export default function fileTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
const id = asset.id;
const idOP = { selections: FILEKEY.ID + "= ?", selectionArgs: ["" + id] };
fetchFileResult.close();
fetchFileResult = await media.getFileAssets(idOP);
let newAsset = await fetchFileResult.getFirstObject();
expect(isNum(newAsset.dateModified)).assertTrue();
expect(newAsset.dateModified).assertEqual(asset.dateModified);
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -76,6 +76,7 @@ export default function fileTestPromiseTest(abilityContext) {
await asset.close(fd);
expect(creatAsset1.id != creatAsset2.id).assertTrue();
console.info(`${testNum} displayName1: ${displayName1}, displayName2 :${displayName2} `);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -104,7 +105,7 @@ export default function fileTestPromiseTest(abilityContext) {
val = displayName;
}
expect(creatAsset[key]).assertEqual(val);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -125,10 +126,12 @@ export default function fileTestPromiseTest(abilityContext) {
const id = asset.id;
const idOP = { selections: FILEKEY.ID + "= ?", selectionArgs: ["" + id] };
fetchFileResult.close();
fetchFileResult = await media.getFileAssets(idOP);
let newAsset = await fetchFileResult.getFirstObject();
expect(isNum(newAsset.dateModified)).assertTrue();
expect(newAsset.dateModified).assertEqual(asset.dateModified);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......
......@@ -59,6 +59,7 @@ export default function fileAssetCallback2Test(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -71,7 +72,8 @@ export default function fileAssetCallback2Test(abilityContext) {
expect(currentAsset[prop]).assertEqual(val);
asset[prop] = oldVal;
await asset.commitModify();
await fetchFileResult.close();
fetchFileResult.close();
await fetchFileResultById.close();
done();
});
} catch (error) {
......@@ -92,10 +94,12 @@ export default function fileAssetCallback2Test(abilityContext) {
if (err) {
console.info(`${testNum} passed : ${err}`);
expect(true).assertTrue();
fetchFileResult.close();
done();
return;
}
expect().assertFail();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -343,10 +347,12 @@ export default function fileAssetCallback2Test(abilityContext) {
if (err) {
console.info(`${testNum} err : ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
expect(isDir).assertEqual(false);
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -56,7 +56,9 @@ export default function fileAssetPromise2Test(abilityContext) {
asset[prop] = oldVal;
await asset.commitModify();
await fetchFileResult.close();
fetchFileResult.close();
await fetchFileResultById.close();
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
......@@ -74,10 +76,12 @@ export default function fileAssetPromise2Test(abilityContext) {
asset[prop] = val;
console.info(`${testNum} failed`);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} passed : ${error}`);
expect(true).assertTrue();
fetchFileResult.close();
done();
}
done();
......@@ -98,10 +102,12 @@ export default function fileAssetPromise2Test(abilityContext) {
try {
await asset.commitModify();
expect().assertFail();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} passed : ${error}`);
expect(true).assertTrue();
fetchFileResult.close();
done();
}
} catch (error) {
......@@ -379,6 +385,7 @@ export default function fileAssetPromise2Test(abilityContext) {
const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory();
expect(isDir).assertEqual(false);
fetchFileResult.close();
done();
} catch (error) {
console.info("FileAsset isDirectory 001 failed, message = " + error);
......
......@@ -57,6 +57,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} :: err: ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -81,6 +82,8 @@ export default function fileAssetTestCallbackTest(abilityContext) {
if (!checkAssetCountPass) return;
let newAsset = await newFetchFileResult.getFirstObject();
expect(newAsset.dateModified != asset.dateModified).assertTrue();
fetchFileResult.close();
newFetchFileResult.close();
done();
});
} catch (error) {
......@@ -104,6 +107,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} :: err: ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -118,6 +122,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
} catch (error) {
expect(true).assertTrue();
await asset.close(fd);
fetchFileResult.close();
done();
}
});
......@@ -144,6 +149,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} :: err: ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -161,6 +167,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
} catch (error) {
expect(true).assertTrue();
}
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -186,6 +193,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} :: err: ${err}`);
expect().assertFail();
fetchFileResult.close();
done();
return;
}
......@@ -203,6 +211,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
}
await sleep(1000);
expect(count).assertEqual(2);
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -75,6 +75,8 @@ export default function fileAssetTestPromiseTest(abilityContext) {
if (!checkAssetCountPass) return;
let newAsset = await newFetchFileResult.getFirstObject();
expect(newAsset.dateModified != asset.dateModified).assertTrue();
fetchFileResult.close();
newFetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} :: error: ${error}`);
......@@ -105,6 +107,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
} catch (error) {
expect(true).assertTrue();
await asset.close(fd);
fetchFileResult.close();
done();
}
} catch (error) {
......@@ -141,6 +144,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
} catch (error) {
expect(true).assertTrue();
}
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} :: error: ${error}`);
......@@ -176,6 +180,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
}
await sleep(1000);
expect(count).assertEqual(2);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} error:${error}`);
......
......@@ -80,10 +80,12 @@ export default function filekeyTestCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
const assetType = asset[type];
let Op = {
selections: fileKey + "= ?",
selectionArgs: [asset[type] + ""],
selectionArgs: [assetType + ""],
};
fetchFileResult.close();
media.getFileAssets(Op, async (err, fetchFileResult) => {
if (err) {
console.info(`${testNum}, err: ${err}`);
......@@ -93,8 +95,9 @@ export default function filekeyTestCallbackTest(abilityContext) {
}
const fetchCount = fetchFileResult.getCount();
const currentAsset = await fetchFileResult.getFirstObject();
expect(currentAsset[type]).assertEqual(asset[type]);
expect(currentAsset[type]).assertEqual(assetType);
expect(fetchCount > 0).assertTrue();
fetchFileResult.close();
done();
});
} catch (error) {
......
......@@ -77,15 +77,18 @@ export default function filekeyTestPromiseTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
const assetType = asset[type];
let Op = {
selections: fileKey + "= ?",
selectionArgs: [asset[type] + ""],
selectionArgs: [assetType + ""],
};
fetchFileResult.close();
fetchFileResult = await media.getFileAssets(Op);
const fetchCount = fetchFileResult.getCount();
expect(fetchCount > 0).assertTrue();
let firstObject = await fetchFileResult.getFirstObject();
expect(firstObject[type]).assertEqual(asset[type]);
expect(firstObject[type]).assertEqual(assetType);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
......
......@@ -51,7 +51,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
media.getFileAssets(fetchOp, async (err, fetchFileResult) => {
let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount);
expect(checkResult).assertTrue();
await fetchFileResult.close();
fetchFileResult.close();
done();
});
} catch (error) {
......@@ -76,6 +76,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
fetchFileResult.getPositionObject(pos, async (err, targetObject) => {
if (err) {
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......@@ -103,6 +104,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
fetchFileResult.getAllObject(async (err, targetObjects) => {
if (err) {
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......@@ -211,6 +213,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......@@ -253,6 +256,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
return;
}
......
......@@ -40,7 +40,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
let fetchFileResult = await media.getFileAssets(fetchOp);
let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount);
expect(checkResult).assertTrue();
await fetchFileResult.close();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
......@@ -425,6 +425,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
try {
await fetchFileResult.getPositionObject(expectCount);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} passed error: ${error}`);
......
......@@ -89,6 +89,7 @@ export default function getExifNoLocation(abilityContext) {
expect(value2).assertEqual(redactionGpsValue);
expect(value3).assertEqual(redactionRefValue);
expect(value4).assertEqual(redactionRefValue);
fetchFileResult.close();
done();
} catch (error) {
console.info("SUB_MEDIA_MEDIALIBRARY_GETEXIFNOLOCATION_001 error: " + error);
......
......@@ -92,6 +92,7 @@ export default function getExifLocation(abilityContext) {
expect(value2.search("9") != -1).assertTrue();
expect(value3).assertEqual("N");
expect(value4).assertEqual("W");
fetchFileResult.close();
done();
} catch (error) {
console.info("SUB_MEDIA_MEDIALIBRARY_GETEXIFLOCATION_001 error: " + error);
......
......@@ -59,6 +59,7 @@ export default function getThumbnailCallback(abilityContext) {
await pixelmap.getImageInfo((err, info) => {
expect(info.size.width).assertEqual(size.width);
expect(info.size.height).assertEqual(size.height);
fetchFileResult.close();
done();
});
});
......@@ -67,6 +68,7 @@ export default function getThumbnailCallback(abilityContext) {
await pixelmap.getImageInfo((err, info) => {
expect(info.size.width).assertEqual(size.width);
expect(info.size.height).assertEqual(size.height);
fetchFileResult.close();
done();
});
});
......@@ -88,17 +90,20 @@ export default function getThumbnailCallback(abilityContext) {
if (err) {
console.info(`${testNum}:: err :${err}`);
expect(true).assertTrue();
fetchFileResult.close();
done();
return;
}
if (pixelmap == undefined) {
expect(true).assertTrue();
fetchFileResult.close();
done();
} else {
const info = await pixelmap.getImageInfo();
console.info(`${testNum} pixel width: ${info.size.width}`);
console.info(`${testNum} pixel height: ${info.size.height}`);
expect(info.size.width == size.width || info.size.height == size.height).assertFalse();
fetchFileResult.close();
done();
}
});
......
......@@ -61,6 +61,7 @@ export default function getThumbnailPromise(abilityContext) {
let info = await pixelmap.getImageInfo();
expect(info.size.width).assertEqual(size.width);
expect(info.size.height).assertEqual(size.height);
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
......@@ -75,15 +76,25 @@ export default function getThumbnailPromise(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchFileResult.getFirstObject();
try {
let s: mediaLibrary.Size = size;
let pixelmap = await asset.getThumbnail(s);
let info = await pixelmap.getImageInfo();
console.info(`${testNum}:: pixel width ${info.size.width},pixel height: ${info.size.height}`);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
fetchFileResult.close();
done();
}
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
}
......
......@@ -51,7 +51,10 @@ export default function mediafetchoptionsCallback(abilityContext) {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
if (!checkAssetCountPass) return;
if (!checkAssetCountPass) {
fetchFileResult.close();
return;
}
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
......@@ -68,6 +71,8 @@ export default function mediafetchoptionsCallback(abilityContext) {
if (err) {
console.info(`${testNum}, err: ${err}`);
expect(false).assertTrue();
fetchFileResult.close();
await result.close();
done();
return;
}
......@@ -76,6 +81,8 @@ export default function mediafetchoptionsCallback(abilityContext) {
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
fetchFileResult.close();
await result.close();
done();
});
} catch (error) {
......
......@@ -69,6 +69,8 @@ export default function mediafetchoptionsPromise(abilityContext) {
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
fetchFileResult.close();
await result.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -157,6 +159,7 @@ export default function mediafetchoptionsPromise(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
expect(checkAssetCountPass).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......@@ -185,6 +188,7 @@ export default function mediafetchoptionsPromise(abilityContext) {
try {
const fetchFileResult = await media.getFileAssets(currentFetchOps);
expect(false).assertTrue();
fetchFileResult.close();
done();
} catch (err) {
expect(true).assertTrue();
......@@ -217,6 +221,7 @@ export default function mediafetchoptionsPromise(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
expect(checkAssetCountPass).assertTrue();
fetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`);
......
......@@ -60,6 +60,7 @@ export default function trashCallback(abilityContext) {
let albumFetchFileResult = await album.getFileAssets();
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(count);
albumFetchFileResult.close();
}
// file info
let asset = await databaseFetchFileResult.getFirstObject();
......@@ -71,6 +72,7 @@ export default function trashCallback(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
return;
}
......@@ -78,12 +80,14 @@ export default function trashCallback(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
return;
}
expect(trashState).assertTrue();
try {
// after trash database info
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let databaseCount = databaseFetchFileResult.getCount();
......@@ -94,6 +98,7 @@ export default function trashCallback(abilityContext) {
let album = albumList[0];
let albumFetchFileResult = await album.getFileAssets();
let albumFilesCount = albumFetchFileResult.getCount();
albumFetchFileResult.close();
expect(albumFilesCount).assertEqual(count - 1);
}
let assetOpts = fileIdFetchOps(id);
......@@ -101,10 +106,13 @@ export default function trashCallback(abilityContext) {
let afterTrashAssetConut = trashAssetResult.getCount();
expect(afterTrashAssetConut).assertEqual(0);
await asset.trash(false);
databaseFetchFileResult.close();
trashAssetResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
}
});
......@@ -128,12 +136,14 @@ export default function trashCallback(abilityContext) {
if (!istrash) {
console.info(`${testNum} istrash failed: ${istrash}`);
expect(istrash).assertFalse();
databaseFetchFileResult.close();
return;
}
asset.trash(false, async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
return;
}
......@@ -141,11 +151,13 @@ export default function trashCallback(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
return;
}
expect(trashState).assertFalse();
try {
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let databaseCount = databaseFetchFileResult.getCount();
expect(databaseCount).assertEqual(count);
......@@ -156,6 +168,7 @@ export default function trashCallback(abilityContext) {
let albumFetchFileResult = await album.getFileAssets();
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(count);
albumFetchFileResult.close();
}
// asset after trash Conut
let assetOpts = fileIdFetchOps(testNum, id);
......@@ -165,10 +178,13 @@ export default function trashCallback(abilityContext) {
let recoveryAsset = await recoveryAssetResult.getFirstObject();
let recoveryAssetState = await recoveryAsset.isTrash();
expect(recoveryAssetState).assertFalse();
databaseFetchFileResult.close();
await recoveryAssetResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
}
});
......@@ -182,6 +198,7 @@ export default function trashCallback(abilityContext) {
async function trashError(done, testNum, databasefFetchOps, value) {
try {
let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
try {
let asset = await databaseFetchFileResult.getFirstObject();
let count = databaseFetchFileResult.getCount();
console.info(`${testNum}count:${count}`);
......@@ -190,17 +207,27 @@ export default function trashCallback(abilityContext) {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
return;
}
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
});
} catch (error) {
console.info(`${testNum} error: ${error}`);
let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let count2 = databaseFetchFileResult.getCount();
expect(count).assertEqual(count2);
databaseFetchFileResult.close();
done();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
}
} catch (error) {
......
......@@ -55,6 +55,7 @@ export default function trashPromise(abilityContext) {
var albumFetchFileResult = await album.getFileAssets();
var albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(count);
albumFetchFileResult.close();
}
// file info
......@@ -66,6 +67,7 @@ export default function trashPromise(abilityContext) {
await asset.trash(true);
istrash = await asset.isTrash();
console.info(`${testNum} istrash: ${istrash}`);
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let databaseCount = databaseFetchFileResult.getCount();
expect(databaseCount).assertEqual(count - 1);
......@@ -76,6 +78,7 @@ export default function trashPromise(abilityContext) {
var albumFetchFileResult = await album.getFileAssets();
var albumFilesCount = albumFetchFileResult.getCount();
expect(databaseCount).assertEqual(count - 1);
albumFetchFileResult.close();
}
// asset after trash Conut
......@@ -84,6 +87,8 @@ export default function trashPromise(abilityContext) {
let afterTrashAssetConut = trashAssetResult.getCount();
expect(afterTrashAssetConut).assertEqual(0);
await asset.trash(false);
databaseFetchFileResult.close();
await trashAssetResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
......@@ -95,17 +100,27 @@ export default function trashPromise(abilityContext) {
async function trashError(done, testNum, databasefFetchOps, value) {
try {
let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
try {
let asset = await databaseFetchFileResult.getFirstObject();
let count = databaseFetchFileResult.getCount();
try {
await asset.trash(value);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let count2 = databaseFetchFileResult.getCount();
expect(count).assertEqual(count2);
databaseFetchFileResult.close();
done();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
databaseFetchFileResult.close();
done();
}
} catch (error) {
......@@ -127,10 +142,12 @@ export default function trashPromise(abilityContext) {
if (!istrash) {
console.info(`${testNum} istrash failed: ${istrash}`);
expect(istrash).assertFalse();
databaseFetchFileResult.close();
return;
}
await asset.trash(false);
databaseFetchFileResult.close();
databaseFetchFileResult = await media.getFileAssets(databasefFetchOps);
let databaseCount = databaseFetchFileResult.getCount();
expect(databaseCount).assertEqual(count);
......@@ -141,6 +158,7 @@ export default function trashPromise(abilityContext) {
let albumFetchFileResult = await album.getFileAssets();
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(count);
albumFetchFileResult.close();
}
// asset after trash Conut
......@@ -151,7 +169,8 @@ export default function trashPromise(abilityContext) {
let recoveryAsset = await recoveryAssetResult.getFirstObject();
let recoveryAssetState = await recoveryAsset.isTrash();
expect(recoveryAssetState).assertFalse();
databaseFetchFileResult.close();
await recoveryAssetResult.close();
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册