1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Add a couple of basic unit-tests for PDFPageViewBuffer

The `PDFPageViewBuffer`-code is very important for the correct function of the viewer, but it's currently not tested at all.
While the `PDFPageViewBuffer` is obviously intended to be used with `PDFPageView`-instances, it only accesses a couple of `PDFPageView` properties/methods and consequently it's fairly easy to unit-test this code with dummy-data.

These unit-tests should help improve our confidence in this code, and will also come in handy with other changes that I'm working on (regarding modernizing and re-factoring the `PDFPageViewBuffer`-code).
This commit is contained in:
Jonas Jenwald 2021-11-05 14:29:02 +01:00
parent e136afbabc
commit fe205efd8d
4 changed files with 176 additions and 1 deletions

View file

@ -127,6 +127,17 @@ function PDFPageViewBuffer(size) {
this.has = function (view) {
return data.includes(view);
};
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
Object.defineProperty(this, "_buffer", {
get() {
return data.slice();
},
});
}
}
function isSameScale(oldScale, newScale) {
@ -1879,4 +1890,4 @@ class BaseViewer {
}
}
export { BaseViewer };
export { BaseViewer, PDFPageViewBuffer };