Remove redundant done
-callback functions from unit-tests which are async
For unit-tests which are asynchronous, using a `done`-callback is redundant and future Jasmine versions will stop supporting that pattern.
This commit is contained in:
parent
4814e23310
commit
eeda2215d7
@ -79,7 +79,7 @@ describe("annotation", function () {
|
|||||||
|
|
||||||
let pdfManagerMock, idFactoryMock, partialEvaluator;
|
let pdfManagerMock, idFactoryMock, partialEvaluator;
|
||||||
|
|
||||||
beforeAll(async function (done) {
|
beforeAll(async function () {
|
||||||
pdfManagerMock = new PDFManagerMock({
|
pdfManagerMock = new PDFManagerMock({
|
||||||
docBaseUrl: null,
|
docBaseUrl: null,
|
||||||
});
|
});
|
||||||
@ -108,8 +108,6 @@ describe("annotation", function () {
|
|||||||
fontCache: new RefSetCache(),
|
fontCache: new RefSetCache(),
|
||||||
builtInCMapCache,
|
builtInCMapCache,
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
|
@ -2033,78 +2033,70 @@ describe("api", function () {
|
|||||||
.catch(done.fail);
|
.catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("caches image resources at the document/page level as expected (issue 11878)", async function (done) {
|
it("caches image resources at the document/page level as expected (issue 11878)", async function () {
|
||||||
const { NUM_PAGES_THRESHOLD } = GlobalImageCache,
|
const { NUM_PAGES_THRESHOLD } = GlobalImageCache,
|
||||||
EXPECTED_WIDTH = 2550,
|
EXPECTED_WIDTH = 2550,
|
||||||
EXPECTED_HEIGHT = 3300;
|
EXPECTED_HEIGHT = 3300;
|
||||||
|
|
||||||
const loadingTask = getDocument(buildGetDocumentParams("issue11878.pdf"));
|
const loadingTask = getDocument(buildGetDocumentParams("issue11878.pdf"));
|
||||||
|
const pdfDoc = await loadingTask.promise;
|
||||||
let firstImgData = null;
|
let firstImgData = null;
|
||||||
|
|
||||||
try {
|
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
||||||
const pdfDoc = await loadingTask.promise;
|
const pdfPage = await pdfDoc.getPage(i);
|
||||||
|
const opList = await pdfPage.getOperatorList();
|
||||||
|
|
||||||
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
const { commonObjs, objs } = pdfPage;
|
||||||
const pdfPage = await pdfDoc.getPage(i);
|
const imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
|
||||||
const opList = await pdfPage.getOperatorList();
|
const [objId, width, height] = opList.argsArray[imgIndex];
|
||||||
|
|
||||||
const { commonObjs, objs } = pdfPage;
|
if (i < NUM_PAGES_THRESHOLD) {
|
||||||
const imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
|
expect(objId).toEqual(`img_p${i - 1}_1`);
|
||||||
const [objId, width, height] = opList.argsArray[imgIndex];
|
|
||||||
|
|
||||||
if (i < NUM_PAGES_THRESHOLD) {
|
expect(objs.has(objId)).toEqual(true);
|
||||||
expect(objId).toEqual(`img_p${i - 1}_1`);
|
expect(commonObjs.has(objId)).toEqual(false);
|
||||||
|
} else {
|
||||||
|
expect(objId).toEqual(
|
||||||
|
`g_${loadingTask.docId}_img_p${NUM_PAGES_THRESHOLD - 1}_1`
|
||||||
|
);
|
||||||
|
|
||||||
expect(objs.has(objId)).toEqual(true);
|
expect(objs.has(objId)).toEqual(false);
|
||||||
expect(commonObjs.has(objId)).toEqual(false);
|
expect(commonObjs.has(objId)).toEqual(true);
|
||||||
} else {
|
|
||||||
expect(objId).toEqual(
|
|
||||||
`g_${loadingTask.docId}_img_p${NUM_PAGES_THRESHOLD - 1}_1`
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(objs.has(objId)).toEqual(false);
|
|
||||||
expect(commonObjs.has(objId)).toEqual(true);
|
|
||||||
}
|
|
||||||
expect(width).toEqual(EXPECTED_WIDTH);
|
|
||||||
expect(height).toEqual(EXPECTED_HEIGHT);
|
|
||||||
|
|
||||||
// Ensure that the actual image data is identical for all pages.
|
|
||||||
if (i === 1) {
|
|
||||||
firstImgData = objs.get(objId);
|
|
||||||
|
|
||||||
expect(firstImgData.width).toEqual(EXPECTED_WIDTH);
|
|
||||||
expect(firstImgData.height).toEqual(EXPECTED_HEIGHT);
|
|
||||||
|
|
||||||
expect(firstImgData.kind).toEqual(ImageKind.RGB_24BPP);
|
|
||||||
expect(firstImgData.data instanceof Uint8ClampedArray).toEqual(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
expect(firstImgData.data.length).toEqual(25245000);
|
|
||||||
} else {
|
|
||||||
const objsPool = i >= NUM_PAGES_THRESHOLD ? commonObjs : objs;
|
|
||||||
const currentImgData = objsPool.get(objId);
|
|
||||||
|
|
||||||
expect(currentImgData.width).toEqual(firstImgData.width);
|
|
||||||
expect(currentImgData.height).toEqual(firstImgData.height);
|
|
||||||
|
|
||||||
expect(currentImgData.kind).toEqual(firstImgData.kind);
|
|
||||||
expect(currentImgData.data instanceof Uint8ClampedArray).toEqual(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
currentImgData.data.every((value, index) => {
|
|
||||||
return value === firstImgData.data[index];
|
|
||||||
})
|
|
||||||
).toEqual(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
expect(width).toEqual(EXPECTED_WIDTH);
|
||||||
|
expect(height).toEqual(EXPECTED_HEIGHT);
|
||||||
|
|
||||||
await loadingTask.destroy();
|
// Ensure that the actual image data is identical for all pages.
|
||||||
firstImgData = null;
|
if (i === 1) {
|
||||||
done();
|
firstImgData = objs.get(objId);
|
||||||
} catch (ex) {
|
|
||||||
done.fail(ex);
|
expect(firstImgData.width).toEqual(EXPECTED_WIDTH);
|
||||||
|
expect(firstImgData.height).toEqual(EXPECTED_HEIGHT);
|
||||||
|
|
||||||
|
expect(firstImgData.kind).toEqual(ImageKind.RGB_24BPP);
|
||||||
|
expect(firstImgData.data instanceof Uint8ClampedArray).toEqual(true);
|
||||||
|
expect(firstImgData.data.length).toEqual(25245000);
|
||||||
|
} else {
|
||||||
|
const objsPool = i >= NUM_PAGES_THRESHOLD ? commonObjs : objs;
|
||||||
|
const currentImgData = objsPool.get(objId);
|
||||||
|
|
||||||
|
expect(currentImgData.width).toEqual(firstImgData.width);
|
||||||
|
expect(currentImgData.height).toEqual(firstImgData.height);
|
||||||
|
|
||||||
|
expect(currentImgData.kind).toEqual(firstImgData.kind);
|
||||||
|
expect(currentImgData.data instanceof Uint8ClampedArray).toEqual(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
currentImgData.data.every((value, index) => {
|
||||||
|
return value === firstImgData.data[index];
|
||||||
|
})
|
||||||
|
).toEqual(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await loadingTask.destroy();
|
||||||
|
firstImgData = null;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("Multiple `getDocument` instances", function () {
|
describe("Multiple `getDocument` instances", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user